Skip to content

Conversation

@gergely-kurucz-konghq
Copy link
Contributor

@gergely-kurucz-konghq gergely-kurucz-konghq commented Jan 25, 2026

Summary by CodeRabbit

  • Refactor
    • Improved internal metadata handling consistency across billing, customer, meter, subscription, and app services through standardized conversion logic.

✏️ Tip: You can customize this high-level summary in your review settings.

@gergely-kurucz-konghq gergely-kurucz-konghq requested a review from a team as a code owner January 25, 2026 14:58
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 25, 2026

📝 Walkthrough

Walkthrough

This PR unifies metadata-to-labels conversion across API handlers by changing ConvertMetadataToLabels to accept models.Metadata instead of map[string]string. It removes duplicate conversion helpers from generated code and implements the standardized function across multiple handler packages (apps, billing profiles, customers, meters, subscriptions), while updating the App interface and its implementation to use strongly-typed metadata.

Changes

Cohort / File(s) Change Summary
Apps handler metadata conversion
api/v3/handlers/apps/convert.go, api/v3/handlers/apps/convert.gen.go
Updated ConvertMetadataToLabels signature from map[string]string to models.Metadata, removed generated helper, and implemented new function to populate labels from source metadata.
Billing profiles handler
api/v3/handlers/billingprofiles/convert.gen.go, api/v3/handlers/billingprofiles/convert.go
Removed duplicate billingMetadataToPV3Labels and billingMetadataToV3Labels helpers, added new ConvertMetadataToLabels accepting billing.Metadata.
Customers handler
api/v3/handlers/customers/convert.gen.go, api/v3/handlers/customers/convert.go
Removed modelsMetadataToV3Labels and pModelsMetadataToPV3Labels helpers, added new ConvertMetadataToLabels accepting pointer to models.Metadata.
Meters handler
api/v3/handlers/meters/convert.gen.go, api/v3/handlers/meters/convert.go
Removed modelsMetadataToPV3Labels and modelsMetadataToV3Labels helpers, added new ConvertMetadataToLabels accepting models.Metadata.
Subscriptions handler
api/v3/handlers/subscriptions/convert.go
Replaced direct api.Labels construction with new unexported convertMetadataToLabels helper ensuring non-nil labels.
App type changes
openmeter/app/app.go, openmeter/app/appbase.go
Changed GetMetadata() return type and Metadata field from map[string]string to models.Metadata.
App HTTP driver
openmeter/app/httpdriver/mapper.go
Updated Stripe and Custom Invoicing metadata handling to use api.Metadata() wrapper on result of GetMetadata().

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • openmeterio/openmeter#3782: Directly modifies the same ConvertMetadataToLabels function signature in apps conversion layer that this PR refactors.
  • openmeterio/openmeter#2678: Changes metadata type from map[string]string to models.Metadata and updates ConvertMetadataToLabels usages across handlers.
  • openmeterio/openmeter#3794: Modifies metadata handling in customer billing and App metadata surfaces with similar type conversions.

Suggested labels

area/api, area/apps

Suggested reviewers

  • tothandras
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: consolidating metadata-to-labels conversion logic across multiple handlers by introducing new ConvertMetadataToLabels functions and updating the App interface to use a strongly-typed models.Metadata type.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/api-v3-handlers-labels-empty

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@gergely-kurucz-konghq gergely-kurucz-konghq added the release-note/ignore Ignore this change when generating release notes label Jan 25, 2026
@gergely-kurucz-konghq gergely-kurucz-konghq merged commit dc078b1 into main Jan 26, 2026
28 of 29 checks passed
@gergely-kurucz-konghq gergely-kurucz-konghq deleted the fix/api-v3-handlers-labels-empty branch January 26, 2026 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/ignore Ignore this change when generating release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants