Skip to content

feat(billing): write feature title and metadata as given on UpdateFeature - #2045

Open
rohilsurana wants to merge 1 commit into
mainfrom
feat/update-feature-full-write
Open

rohilsurana wants to merge 1 commit into
mainfrom
feat/update-feature-full-write

Conversation

@rohilsurana

@rohilsurana rohilsurana commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

What

The UpdateFeature API now saves a feature's title, metadata and product links exactly as sent.

  • A title sent as empty clears the title.
  • Metadata sent as empty, or left out, is saved as {}.
  • Updating a feature name that does not exist now returns NotFound. Before, it quietly created the feature.
  • The feature is found by body.name only. The request id is ignored, as it was before this change. A name that looks like a UUID is still treated as a name.

Why

Before this change, UpdateFeature kept the old title and metadata when the request sent them empty. So there was no way to clear them through the API.

Declarative reconcile needs that. Its rule is that a field left out of the file goes back to its default (RFC 0001). The new BillingFeature reconcile kind uses this API to set feature titles and tooltips from a file.

UpdateProduct already works this way for product titles.

What does not change

  • UpsertFeature keeps its old merge behavior.
  • Creating a product, adding a feature to a product, and CreatePlan still go through UpsertFeature. Those calls send feature names only, so they can't wipe a title or metadata.
  • Only the UpdateFeature handler uses the new product.Service.UpdateFeature.

For callers

A client that calls UpdateFeature with only some fields filled will now clear the fields it leaves out. No caller in this repo does that.

Tests

  • Service tests:
    • a title is cleared
    • nil metadata is saved as {}
    • a non-empty title and metadata are saved as given
    • product links are written
    • an unknown name returns not found
    • an empty name is rejected
    • a name that looks like a UUID is still looked up by name
  • Handler tests: empty and filled-in fields pass through, NotFound is returned, and InvalidArgument is returned.

Related

The BillingFeature reconcile kind is in #2046. That PR does not depend on this one to build. A reset (a title or metadata left out of the file) only applies after this PR is merged.

@vercel

vercel Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
frontier Ready Ready Preview Nov 6, 2026 8:22pm UTC

@coderabbitai

coderabbitai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • New Features
    • Added support for updating existing billing product features. Updates replace the feature’s title, product associations, and metadata with the supplied values, and duplicate product associations are removed.
    • Updates can clear existing metadata by supplying empty metadata.
  • Error Handling
    • Requests for features that don’t exist return a not-found error. Invalid feature details, including an empty feature name, return an invalid-argument error.

The product service now updates existing features by name. The Connect handler calls the update operation and returns its result or an error.

Changes: Feature Update

Layer / File(s) Summary
Product service update
billing/product/service.go, billing/product/service_test.go
Adds UpdateFeature to replace existing feature fields, deduplicate product IDs, initialize nil metadata to an empty metadata map, and persist the result. Service tests cover field replacement, UUID-shaped names, and error cases.
Connect update integration
internal/api/v1beta1connect/interfaces.go, internal/api/v1beta1connect/billing_product.go, internal/api/v1beta1connect/mocks/product_service.go, internal/api/v1beta1connect/billing_product_test.go
Adds UpdateFeature to the service interface and mock. The Connect handler calls it, and tests cover successful responses and error codes.

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Feature

Possibly related PRs

  • raystack/frontier#2046: Uses UpdateFeature to reconcile feature titles and metadata. This PR’s update operation resets omitted values to empty values.

Suggested reviewers: amangit07

Merge Risk: Minimal · up to 99600

UpdateFeature now writes title, metadata and product links as given, and returns NotFound for an unknown feature name. No remaining merge-blocking risk was identified. Callers that send only some fields will clear the omitted ones, as the author notes.

Pre-merge checks: Passed 2

Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 2ce60db and 99600f1.

Files selected for processing: 3

  • billing/product/service.go
  • billing/product/service_test.go
  • internal/api/v1beta1connect/billing_product_test.go

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@coveralls

coveralls commented Nov 6, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 42287764341

Coverage increased (+0.06%) to 56.116%

Details

  • Coverage increased (+0.06%) from the base build.
  • Patch coverage: 17 of 17 lines across 2 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 42204
Covered Lines: 23683
Line Coverage: 56.12%
Coverage Strength: 19.7 hits per line

💛 - Coveralls

@rohilsurana
rohilsurana marked this pull request as ready for review November 6, 2026 09:21

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Nitpick comments: 2

billing/product/service_test.go: 1

1292-1297: Trivial · Functional Correctness · Low value

Test clearing existing product links.

The nil-input case starts with no product links. A regression that preserves existing links for an empty input would pass. Give the fixture an existing link so the UpdateByName expectation verifies its removal.

Suggested fix

-					ID:       "1",
-					Name:     "feature1",
-					Title:    "Feature 1",
-					Metadata: metadata.Metadata{"info": "tooltip"},
+					ID:         "1",
+					Name:       "feature1",
+					Title:      "Feature 1",
+					ProductIDs: []string{"1"},
+					Metadata:   metadata.Metadata{"info": "tooltip"},
internal/api/v1beta1connect/billing_product_test.go: 1

1183-1195: Trivial · Maintainability & Code Quality · Low value

Add a populated update case.

The successful handler test uses empty title and metadata values. It cannot detect an UpdateFeature-specific regression that drops populated values. Add a case that checks both fields in the service call and response. Compare the response metadata with the expected value.

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between f38ac11 and 2ce60db.

Files selected for processing: 6

  • billing/product/service.go
  • billing/product/service_test.go
  • internal/api/v1beta1connect/billing_product.go
  • internal/api/v1beta1connect/billing_product_test.go
  • internal/api/v1beta1connect/interfaces.go
  • internal/api/v1beta1connect/mocks/product_service.go

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

Comment thread billing/product/service.go Resolved

This branch was successfully deployed

1 active deployment
Preview — 99600f1b Deployed Nov 6, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants