-
Notifications
You must be signed in to change notification settings - Fork 124
fix(api): use external key for feature #3397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -16629,16 +16629,20 @@ components: | |||||||||||||||||||||||||||
key: | ||||||||||||||||||||||||||||
type: string | ||||||||||||||||||||||||||||
minLength: 1 | ||||||||||||||||||||||||||||
maxLength: 64 | ||||||||||||||||||||||||||||
pattern: ^[a-z0-9]+(?:_[a-z0-9]+)*$ | ||||||||||||||||||||||||||||
description: A key is a unique string that is used to identify a resource. | ||||||||||||||||||||||||||||
maxLength: 256 | ||||||||||||||||||||||||||||
description: |- | ||||||||||||||||||||||||||||
The unique key of the feature | ||||||||||||||||||||||||||||
Useful to reference the feature in external systems. | ||||||||||||||||||||||||||||
For example, your database ID. | ||||||||||||||||||||||||||||
title: The unique key of the feature | ||||||||||||||||||||||||||||
name: | ||||||||||||||||||||||||||||
type: string | ||||||||||||||||||||||||||||
description: The human-readable name of the feature | ||||||||||||||||||||||||||||
title: The human-readable name of the feature | ||||||||||||||||||||||||||||
metadata: | ||||||||||||||||||||||||||||
allOf: | ||||||||||||||||||||||||||||
- $ref: '#/components/schemas/Metadata' | ||||||||||||||||||||||||||||
description: Optional metadata | ||||||||||||||||||||||||||||
title: Optional metadata | ||||||||||||||||||||||||||||
Comment on lines
+16632
to
16646
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainExternal feature key: change looks good; please verify backend/storage and SDK impacts. Removing the pattern and increasing maxLength to 256 aligns with using an external key. Please verify:
Run this to find lingering 64-char limits or the old regex: 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Find 64-length constraints
rg -n -C2 -g '!**/dist/**' -g '!**/build/**' -P '\b(maxLength|varchar|VARCHAR|length)\s*[:( ]\s*64\b'
# Find old snake_case pattern
rg -n -C2 -g '!**/dist/**' -g '!**/build/**' '^[ ]*pattern:\s*\^\[a-z0-9\]\+\(\?:_\[a-z0-9\]\+\)\*\$' api
# Find custom validations mentioning 64 or snake_case
rg -n -C2 -P '\b(64|snake[_ -]?case|slug)\b' --type go --type ts --type tsx --type rs --type py Length of output: 148 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "PWD: $(pwd)"
echo "Top-level files:"
ls -la | sed -n '1,200p' || true
echo "Git branch (if available):"
git rev-parse --abbrev-ref HEAD 2>/dev/null || true
echo
echo "Show snippet of api/openapi.cloud.yaml (if exists):"
if [ -f api/openapi.cloud.yaml ]; then
sed -n '16620,16650p' api/openapi.cloud.yaml || true
else
echo "api/openapi.cloud.yaml not found at that path; searching for openapi*.yaml files..."
rg -n --hidden --no-ignore-vcs -S 'openapi.*\.ya?ml' || true
fi
echo
echo "Searching for common 64-length constraints (SQL, YAML, code) across repo:"
rg -n --no-ignore-vcs -S -P 'varchar\s*\(\s*64\s*\)|VARCHAR\s*\(\s*64\s*\)|character varying\s*\(?64\)?|\b(maxLength|max_length|maxlength|length)\b[^0-9\n]*\b64\b' || true
echo
echo "Searching for the snake_case regex or YAML 'pattern:' lines that might enforce it:"
rg -n --no-ignore-vcs -S -P '\^\[a-z0-9\]\+(\?:_\[a-z0-9\]\+)*\$|pattern:\s*\^' || true
echo
echo "Searching for mentions of 'snake_case', 'slug', or related validator terms in common source files:"
rg -n --no-ignore-vcs -S -P '\b(snake[_ -]?case|slug|slugify|slug_)\b' --type-add 'code:*.{go,ts,tsx,rs,py,java,kt,sql,yaml,yml,json}' --type code || true Length of output: 70551 Action required — backend, validators and SDKs must be updated after increasing feature key to 256 Change is present in api/openapi.cloud.yaml (key maxLength: 256) but verification shows many remaining 64-char constraints and snake_case patterns; update everything end-to-end. Key findings and next steps:
|
||||||||||||||||||||||||||||
example: | ||||||||||||||||||||||||||||
key: value | ||||||||||||||||||||||||||||
|
@@ -16647,7 +16651,7 @@ components: | |||||||||||||||||||||||||||
minLength: 1 | ||||||||||||||||||||||||||||
maxLength: 64 | ||||||||||||||||||||||||||||
pattern: ^[a-z0-9]+(?:_[a-z0-9]+)*$ | ||||||||||||||||||||||||||||
description: A key is a unique string that is used to identify a resource. | ||||||||||||||||||||||||||||
description: The meter that the feature is associated with and and based on which usage is calculated. | ||||||||||||||||||||||||||||
title: Meter slug | ||||||||||||||||||||||||||||
example: tokens_total | ||||||||||||||||||||||||||||
Comment on lines
16651
to
16656
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix typo and tighten phrasing in meterSlug description. “and and” is a typo. Suggest clearer wording. Apply: - description: The meter that the feature is associated with and and based on which usage is calculated.
+ description: The meter associated with the feature and used to calculate usage. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||
meterGroupByFilters: | ||||||||||||||||||||||||||||
|
@@ -16681,16 +16685,20 @@ components: | |||||||||||||||||||||||||||
key: | ||||||||||||||||||||||||||||
type: string | ||||||||||||||||||||||||||||
minLength: 1 | ||||||||||||||||||||||||||||
maxLength: 64 | ||||||||||||||||||||||||||||
pattern: ^[a-z0-9]+(?:_[a-z0-9]+)*$ | ||||||||||||||||||||||||||||
description: A key is a unique string that is used to identify a resource. | ||||||||||||||||||||||||||||
maxLength: 256 | ||||||||||||||||||||||||||||
description: |- | ||||||||||||||||||||||||||||
The unique key of the feature | ||||||||||||||||||||||||||||
Useful to reference the feature in external systems. | ||||||||||||||||||||||||||||
For example, your database ID. | ||||||||||||||||||||||||||||
title: The unique key of the feature | ||||||||||||||||||||||||||||
name: | ||||||||||||||||||||||||||||
type: string | ||||||||||||||||||||||||||||
description: The human-readable name of the feature | ||||||||||||||||||||||||||||
title: The human-readable name of the feature | ||||||||||||||||||||||||||||
metadata: | ||||||||||||||||||||||||||||
allOf: | ||||||||||||||||||||||||||||
- $ref: '#/components/schemas/Metadata' | ||||||||||||||||||||||||||||
description: Optional metadata | ||||||||||||||||||||||||||||
title: Optional metadata | ||||||||||||||||||||||||||||
example: | ||||||||||||||||||||||||||||
key: value | ||||||||||||||||||||||||||||
|
@@ -16699,7 +16707,7 @@ components: | |||||||||||||||||||||||||||
minLength: 1 | ||||||||||||||||||||||||||||
maxLength: 64 | ||||||||||||||||||||||||||||
pattern: ^[a-z0-9]+(?:_[a-z0-9]+)*$ | ||||||||||||||||||||||||||||
description: A key is a unique string that is used to identify a resource. | ||||||||||||||||||||||||||||
description: The meter that the feature is associated with and and based on which usage is calculated. | ||||||||||||||||||||||||||||
title: Meter slug | ||||||||||||||||||||||||||||
example: tokens_total | ||||||||||||||||||||||||||||
meterGroupByFilters: | ||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Confirm source-of-truth (generated vs. hand-edited).
If this file is generated from OpenAPI/TypeSpec, ensure these doc changes originate in the spec and the client was re-generated; otherwise they’ll be overwritten on the next generation. Also confirm other language clients were regenerated to keep docs in sync.
Run:
🏁 Script executed:
Length of output: 278130
Action required — spec/client mismatch: OpenAPI widened ExternalKey to 256 but JS validators still enforce old regex/64‑char constraints
api/openapi.yaml contains ULIDOrExternalKey / ExternalKey with minLength:1 maxLength:256 (e.g. the ULIDOrExternalKey component and the feature "key"), but api/client/javascript/src/zod/index.ts still has .regex() checks and 64‑length constraints and api/client/javascript/src/client/schemas.ts (lines 5450–5476) looks like generated docs that will be overwritten. Regenerate the JavaScript client (and any other language clients), or put the doc/constraint changes into the OpenAPI spec and then regenerate; confirm whether schemas.ts is generated or hand‑edited.
🤖 Prompt for AI Agents