Skip to content

fix(api): customerIdOrKey entitlement param type#3093

Merged
tothandras merged 1 commit intomainfrom
fix/api-customer-id-or-key
Jul 11, 2025
Merged

fix(api): customerIdOrKey entitlement param type#3093
tothandras merged 1 commit intomainfrom
fix/api-customer-id-or-key

Conversation

@tothandras
Copy link
Contributor

@tothandras tothandras commented Jul 11, 2025

Fix customer key for entitlement API

Summary by CodeRabbit

  • New Features

    • Expanded support for customer identifiers in API endpoints to accept both ULID and external key formats.
  • Documentation

    • Updated API documentation and specifications to reflect the new customer identifier format requirements.
  • Bug Fixes

    • Improved validation logic for customer identifiers to support both strict ULID and more flexible external key formats.

@tothandras tothandras requested a review from a team as a code owner July 11, 2025 12:27
@tothandras tothandras added the release-note/bug-fix Release note: Bug Fixes label Jul 11, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 11, 2025

📝 Walkthrough

"""

Walkthrough

This change updates the type of the customerIdOrKey parameter across the API specification, server, client implementations, and validation schemas from a plain string or previous union type to a new shared type alias, ULIDOrExternalKey. All affected API endpoints, schemas, and client libraries now consistently use this type for customer identifiers.

Changes

Files/Paths Change Summary
api/api.gen.go Updated server interface, method signatures, and wrappers to use ULIDOrExternalKey for customerIdOrKey parameter.
api/client/go/client.gen.go Changed client and interface method signatures for customerIdOrKey to ULIDOrExternalKey; updated swagger spec.
api/client/javascript/src/client/schemas.ts Updated parameter type for customerIdOrKey in relevant operations to reference ULIDOrExternalKey.
api/client/javascript/src/zod/index.ts Changed validation: split regex and max length for ULID and external key; parameter schemas now accept union of both.
api/openapi.cloud.yaml
api/openapi.yaml
Path parameter schemas for customerIdOrKey now reference ULIDOrExternalKey component instead of inline string constraints.
api/spec/src/entitlements/customer.tsp Changed method signatures in Customer interface to use ULIDOrExternalKey for customerIdOrKey.

Possibly related PRs

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Biome (1.9.4)
api/client/javascript/src/zod/index.ts

The --json option is unstable/experimental and its output might change between patches/minor releases.
{"summary":{"changed":0,"unchanged":1,"matches":0,"duration":{"secs":5,"nanos":842497541},"errors":475,"warnings":0,"skipped":0,"suggestedFixesSkipped":0,"diagnosticsNotPrinted":0},"diagnostics":[{"category":"lint/complexity/useRegexLiterals","severity":"error","description":"Use a regular expression literal instead of the RegExp constructor.","message":[{"elements":[],"content":"Use a regular expression literal instead of the "},{"elements":["Emphasis"],"content":"RegExp"},{"elements":[],"content":" constructor."}],"advices":{"advices":[{"log":["info",[{"elements":[],"content":"Regular expression literals avoid some escaping required in a string literal, and are easier to analyze statically."}]]},{"log":["info",[{"elements":[],"content":"Safe fix: Use a "},{"elements":["Emphasis"],"content":"literal notation"},{"elements":[],"content":" instead."}]]},{"diff":{"dictionary":"/* eslint-

... [truncated 99999040 characters] ...

eryParams = zod.object({\n channel: zod\n .array(\n zod.coerce\n .string()\n .regex(listNotificationEventsQueryChannelItemRegExp)\n .describe(\n 'ULID (Universally Unique Lexicographically Sortable Identifier).'\n )\n )\n .optional()\n .describe(\n 'Filtering by multiple channel ids.\n\nUsage: `?chanBiome encountered an unexpected error

This is a bug in Biome, not an error in your code, and we would appreciate it if you could report it to https://github.com/biomejs/biome/issues/ along with the following information to help us fixing the issue:

Source Location: crates/biome_console/src/lib.rs:149:14
Thread Name: main
Message: called Result::unwrap() on an Err value: Os { code: 32, kind: BrokenPipe, message: "Broken pipe" }


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0ba9e73 and 292d8a3.

📒 Files selected for processing (6)
  • api/client/go/client.gen.go (13 hunks)
  • api/client/javascript/src/client/schemas.ts (2 hunks)
  • api/client/javascript/src/zod/index.ts (3 hunks)
  • api/openapi.cloud.yaml (2 hunks)
  • api/openapi.yaml (2 hunks)
  • api/spec/src/entitlements/customer.tsp (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
  • api/client/javascript/src/client/schemas.ts
  • api/openapi.yaml
  • api/spec/src/entitlements/customer.tsp
  • api/openapi.cloud.yaml
  • api/client/javascript/src/zod/index.ts
  • api/client/go/client.gen.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: Quickstart
  • GitHub Check: CI
  • GitHub Check: E2E
  • GitHub Check: Test
  • GitHub Check: Commit hooks
  • GitHub Check: Developer environment
  • GitHub Check: Build
  • GitHub Check: Lint
  • GitHub Check: Migration Checks
  • GitHub Check: Analyze (go)
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

hekike
hekike previously approved these changes Jul 11, 2025
chrisgacsal
chrisgacsal previously approved these changes Jul 11, 2025
@tothandras tothandras enabled auto-merge (squash) July 11, 2025 12:32
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
api/openapi.cloud.yaml (1)

3535-3539: Same concern as above – reference must resolve.

This hunk repeats the $ref change; the comment from lines 3247-3251 applies here as well.

🧹 Nitpick comments (2)
api/openapi.yaml (2)

3246-3250: Add/restore a helpful parameter description

The previous inline schema likely carried a short description (e.g., “Customer ULID or external key”). With the switch to a $ref, the description field disappeared, reducing Swagger-UI usability. Consider re-adding it:

 in: path
 required: true
 schema:
   $ref: '#/components/schemas/ULIDOrExternalKey'
+description: Customer ULID (26-char Crockford base32) or external key (≤256 chars)

3536-3537: Mirror the same improvement for the second endpoint

Same remark as above: keep a description alongside the $ref for consistency and better API docs.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e477521 and 0ba9e73.

📒 Files selected for processing (7)
  • api/api.gen.go (7 hunks)
  • api/client/go/client.gen.go (13 hunks)
  • api/client/javascript/src/client/schemas.ts (2 hunks)
  • api/client/javascript/src/zod/index.ts (3 hunks)
  • api/openapi.cloud.yaml (2 hunks)
  • api/openapi.yaml (2 hunks)
  • api/spec/src/entitlements/customer.tsp (2 hunks)
🧰 Additional context used
🧠 Learnings (8)
📓 Common learnings
Learnt from: chrisgacsal
PR: openmeterio/openmeter#2522
File: api/spec/src/productcatalog/routes.tsp:163-314
Timestamp: 2025-03-25T09:13:03.300Z
Learning: ULIDOrKey is defined in api/spec/src/types.tsp as a scalar type with a pattern that validates against both ULID and Key formats, not as a type alias like PlanIdOrKey.
api/spec/src/entitlements/customer.tsp (1)
Learnt from: chrisgacsal
PR: openmeterio/openmeter#2522
File: api/spec/src/productcatalog/routes.tsp:163-314
Timestamp: 2025-03-25T09:13:03.300Z
Learning: ULIDOrKey is defined in api/spec/src/types.tsp as a scalar type with a pattern that validates against both ULID and Key formats, not as a type alias like PlanIdOrKey.
api/client/javascript/src/client/schemas.ts (1)

undefined

<retrieved_learning>
Learnt from: chrisgacsal
PR: #2522
File: api/spec/src/productcatalog/routes.tsp:163-314
Timestamp: 2025-03-25T09:13:03.300Z
Learning: ULIDOrKey is defined in api/spec/src/types.tsp as a scalar type with a pattern that validates against both ULID and Key formats, not as a type alias like PlanIdOrKey.
</retrieved_learning>

api/client/javascript/src/zod/index.ts (1)

undefined

<retrieved_learning>
Learnt from: chrisgacsal
PR: #2522
File: api/spec/src/productcatalog/routes.tsp:163-314
Timestamp: 2025-03-25T09:13:03.300Z
Learning: ULIDOrKey is defined in api/spec/src/types.tsp as a scalar type with a pattern that validates against both ULID and Key formats, not as a type alias like PlanIdOrKey.
</retrieved_learning>

api/openapi.yaml (1)

undefined

<retrieved_learning>
Learnt from: chrisgacsal
PR: #2522
File: api/spec/src/productcatalog/routes.tsp:163-314
Timestamp: 2025-03-25T09:13:03.300Z
Learning: ULIDOrKey is defined in api/spec/src/types.tsp as a scalar type with a pattern that validates against both ULID and Key formats, not as a type alias like PlanIdOrKey.
</retrieved_learning>

api/openapi.cloud.yaml (1)

undefined

<retrieved_learning>
Learnt from: chrisgacsal
PR: #2522
File: api/spec/src/productcatalog/routes.tsp:163-314
Timestamp: 2025-03-25T09:13:03.300Z
Learning: ULIDOrKey is defined in api/spec/src/types.tsp as a scalar type with a pattern that validates against both ULID and Key formats, not as a type alias like PlanIdOrKey.
</retrieved_learning>

api/api.gen.go (1)

undefined

<retrieved_learning>
Learnt from: chrisgacsal
PR: #2522
File: api/spec/src/productcatalog/routes.tsp:163-314
Timestamp: 2025-03-25T09:13:03.300Z
Learning: ULIDOrKey is defined in api/spec/src/types.tsp as a scalar type with a pattern that validates against both ULID and Key formats, not as a type alias like PlanIdOrKey.
</retrieved_learning>

api/client/go/client.gen.go (1)

undefined

<retrieved_learning>
Learnt from: chrisgacsal
PR: #2522
File: api/spec/src/productcatalog/routes.tsp:163-314
Timestamp: 2025-03-25T09:13:03.300Z
Learning: ULIDOrKey is defined in api/spec/src/types.tsp as a scalar type with a pattern that validates against both ULID and Key formats, not as a type alias like PlanIdOrKey.
</retrieved_learning>

🧬 Code Graph Analysis (1)
api/api.gen.go (2)
api/client/go/client.gen.go (2)
  • ULIDOrExternalKey (6216-6216)
  • GetCustomerEntitlementValueParams (6952-6954)
openmeter/customer/httpdriver/customer.go (1)
  • GetCustomerEntitlementValueParams (333-336)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: Quickstart
  • GitHub Check: E2E
  • GitHub Check: CI
  • GitHub Check: Commit hooks
  • GitHub Check: Developer environment
  • GitHub Check: Lint
  • GitHub Check: Build
  • GitHub Check: Test
  • GitHub Check: Migration Checks
  • GitHub Check: Analyze (go)
🔇 Additional comments (27)
api/spec/src/entitlements/customer.tsp (2)

35-35: LGTM! Consistent type usage.

The type change is consistent with the previous change on line 22, ensuring both API endpoints use the same type for customer identification.


22-22: ULIDOrExternalKey type validated
The union ULIDOrExternalKey is correctly defined in api/spec/src/types.tsp and is referenced without import issues in api/spec/src/entitlements/customer.tsp. All OpenAPI schemas and generated clients consistently use this type.

api/client/javascript/src/client/schemas.ts (2)

15570-15572: Mirror change for feature-scoped route—same verification applies.

Same concerns as above: ensure regenerated types are consumed everywhere and versioning communicates the breaking change. Consider adding migration notes to the changelog.


15178-15180: No residual customerIdOrKey: string usages in api

I ran a search across the api directory and found no instances of

customerIdOrKey: string  

Remaining next steps to fully validate this breaking change:

  • Confirm all generated client code has been regenerated to use ULIDOrExternalKey.
  • Audit any handwritten call-sites (outside the generated code) to ensure none still accept a plain string.
  • Verify the SDK/API version in package.json (or equivalent) has been bumped (semver) to reflect this breaking change.
api/openapi.yaml (1)

3248-3249: ULIDOrExternalKey schema is present and declared once
The #/components/schemas/ULIDOrExternalKey reference in api/openapi.yaml is valid—it's defined at line 22482. No further action required.

api/openapi.cloud.yaml (1)

3247-3251: ULIDOrExternalKey schema definition confirmed

  • Definition found at api/openapi.cloud.yaml line 21556
  • References at lines 3045, 3113, 3186, 3250, 3319, 3389, 3467, 3538, 3623

All $ref: '#/components/schemas/ULIDOrExternalKey' entries correctly resolve.

api/client/javascript/src/zod/index.ts (3)

6969-6987: LGTM! Improved type safety with proper ULID validation.

The implementation correctly splits the validation into two distinct cases:

  1. Strict ULID pattern validation with proper Crockford's Base32 encoding
  2. Permissive external key validation (1-256 characters)

The union type approach using .or() provides the flexibility to accept either format while maintaining type safety.


7425-7427: Consistent constant definitions for entitlement value parameters.

The naming convention with "RegExpOne" and "MaxTwo" suffixes effectively distinguishes between the ULID regex pattern and external key maximum length constraints.


7437-7447: Consistent validation schema implementation.

The validation logic matches the implementation in getCustomerAccessParams, ensuring consistent behavior across all customer identifier parameters in the API.

api/api.gen.go (7)

11551-11551: LGTM: Parameter type updated for better type safety.

The change from string to ULIDOrExternalKey for the customerIdOrKey parameter provides better type validation and aligns with the PR objective to standardize customer identifier types across the API.


11563-11563: LGTM: Consistent parameter type update.

The parameter type change maintains consistency with the GetCustomerAccess method and follows the same pattern for customer identifier validation.


12091-12091: LGTM: Unimplemented stub updated to match interface.

The parameter type change in the unimplemented method correctly reflects the interface update, maintaining code consistency and ensuring compilation.


12115-12115: LGTM: Unimplemented stub updated consistently.

The parameter type change maintains consistency with the interface definition and ensures the unimplemented method signature matches the updated interface.


14162-14162: LGTM: Variable type updated for parameter binding.

The variable type change from string to ULIDOrExternalKey is necessary to match the updated method signature and ensure proper parameter binding in the server wrapper.


14298-14298: LGTM: Consistent variable type update.

The variable type change maintains consistency with the previous parameter binding update and ensures proper type handling for the GetCustomerEntitlementValue method.


18839-19057: Generated swagger specification updated.

The embedded swagger specification has been updated to reflect the parameter type changes. Since this appears to be generated/encoded content, detailed review is not feasible, but the update is necessary to maintain consistency between the API implementation and documentation.

api/client/go/client.gen.go (11)

10772-10772: LGTM: Interface method signature updated correctly.

The GetCustomerAccess method signature has been properly updated to use ULIDOrExternalKey type for the customerIdOrKey parameter, which aligns with the PR objective to standardize this parameter type across the API.


10786-10786: LGTM: Interface method signature updated consistently.

The GetCustomerEntitlementValue method signature has been properly updated to use ULIDOrExternalKey type, maintaining consistency with other methods in the interface.


11846-11846: LGTM: Implementation signature matches interface.

The GetCustomerAccess implementation has been properly updated to match the interface signature change, ensuring type consistency across the client implementation.


11906-11906: LGTM: Implementation signature matches interface.

The GetCustomerEntitlementValue implementation has been properly updated to match the interface signature change, maintaining consistency across the client implementation.


16031-16031: LGTM: Request constructor signature updated correctly.

The NewGetCustomerAccessRequest function signature has been properly updated to accept ULIDOrExternalKey type, ensuring consistency with the calling client methods.


16241-16241: LGTM: Request constructor signature updated consistently.

The NewGetCustomerEntitlementValueRequest function signature has been properly updated to accept ULIDOrExternalKey type, maintaining consistency with the client method signatures.


21855-21855: LGTM: ClientWithResponses interface signature updated correctly.

The GetCustomerAccessWithResponse method signature in the ClientWithResponsesInterface has been properly updated to use ULIDOrExternalKey type, maintaining consistency with the base client interface.


21869-21869: LGTM: ClientWithResponses interface signature updated consistently.

The GetCustomerEntitlementValueWithResponse method signature in the ClientWithResponsesInterface has been properly updated to use ULIDOrExternalKey type, ensuring consistency across all client interfaces.


26714-26714: LGTM: ClientWithResponses implementation signature matches interface.

The GetCustomerAccessWithResponse implementation has been properly updated to match the interface signature change, ensuring type consistency across the client with responses implementation.


26758-26758: LGTM: ClientWithResponses implementation signature matches interface.

The GetCustomerEntitlementValueWithResponse implementation has been properly updated to match the interface signature change, maintaining consistency across the client with responses implementation.


38847-39467: LGTM: Embedded swagger specification data updated.

The embedded swagger specification data has been properly updated to reflect the API changes. Since this is a generated file, these base64 encoded changes represent the updated OpenAPI specification that now uses ULIDOrExternalKey instead of string for customerIdOrKey parameters.

This indicates that the code generation process correctly incorporated the API specification changes and maintained consistency between the client code and the underlying API specification.

@tothandras tothandras disabled auto-merge July 11, 2025 12:33
@tothandras tothandras dismissed stale reviews from chrisgacsal and hekike via 292d8a3 July 11, 2025 12:36
@tothandras tothandras force-pushed the fix/api-customer-id-or-key branch from 0ba9e73 to 292d8a3 Compare July 11, 2025 12:36
@tothandras tothandras enabled auto-merge (squash) July 11, 2025 12:37
@tothandras tothandras merged commit d14ae14 into main Jul 11, 2025
21 checks passed
@tothandras tothandras deleted the fix/api-customer-id-or-key branch July 11, 2025 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api release-note/bug-fix Release note: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants