Skip to content

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

Merged
rohilsurana merged 2 commits into
mainfrom
feat/update-feature-full-write
Nov 17, 2026
Merged

rohilsurana merged 2 commits 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 16, 2026 11:08am 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 apply the supplied title, product associations, and metadata; duplicate product associations are removed.
    • Supplying empty metadata clears the feature’s existing metadata.
  • Error Handling
    • Requests for features that don’t exist return a not-found error. Invalid feature details, including an empty or whitespace-only feature name, return an invalid-argument error.

The product service now updates 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 update feature fields by name, deduplicate product IDs, and initialize nil metadata to an empty value. Service tests cover field handling, 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

Suggested reviewers: amangit07

Merge Risk: Minimal · up to 2cc12

UpdateFeature now saves the title, metadata, and product links exactly as sent, and it uses the feature name as the key. No merge-blocking risk was found. Clients that send only some fields will now clear the omitted ones, which is intended.

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 99600f1 and 2cc125f.

Files selected for processing: 2

  • billing/product/service.go
  • billing/product/service_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 43854978327

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage increased (+0.1%) to 56.159%

Details

  • Coverage increased (+0.1%) from the base build.
  • Patch coverage: 16 of 16 lines across 2 files are fully covered (100%).
  • 73 coverage regressions across 3 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

73 previously-covered lines in 3 files lost coverage.

File Lines Losing Coverage Coverage
core/userpat/service.go 53 89.79%
core/membership/org.go 14 86.56%
core/membership/service.go 6 88.82%

Coverage Stats

Coverage Status
Relevant Lines: 42246
Covered Lines: 23725
Line Coverage: 56.16%
Coverage Strength: 21.71 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
Comment thread billing/product/service.go Resolved
@Shreyag02 Shreyag02 mentioned this pull request Nov 16, 2026
4 of 6 tasks
@rohilsurana
rohilsurana merged commit 735de27 into main Nov 17, 2026
8 checks passed
@rohilsurana
rohilsurana deleted the feat/update-feature-full-write branch November 17, 2026 06:57

This branch was successfully deployed

1 active deployment
Preview — 2cc125f0 Deployed Nov 16, 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