fix: allow longer instance ids in api#395
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (10)
📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAPI schema changes replace Identifier with g.String for instance control endpoints and add MinLength(1)/MaxLength(63) to instance identifier fields; an e2e test passes InstanceID as a raw string in the RestartInstance payload. ChangesInstance identifier schema + test
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
api/apiv1/design/api.go (1)
731-741: ⚡ Quick winConsider a shared
InstanceIDtype instead of repeating the inline constraints.The same
g.String+MinLength(1)+MaxLength(63)block is duplicated acrossrestart-instance,stop-instance, andstart-instance, and the relatedcandidate_instance_id(line 382) is a bareg.Stringwith no constraints. Defining a singleInstanceIDtype incommon.go(mirroringIdentifier) would centralize the limit, keep the three endpoints in sync, and letcandidate_instance_idreuse it. Note this also dropsIdentifier's charset rules forinstance_id; since these values are used directly as storage keys that's acceptable, but a dedicated type documents the looser contract explicitly.♻️ Sketch of a shared type in common.go
var InstanceID = g.Type("InstanceID", g.String, func() { g.Description("An instance identifier: database_id + node name + host hash. 1-63 characters.") g.MinLength(1) g.MaxLength(63) g.Example("68f50878-44d2-4524-a823-e31bd478706d-n1-689qacsi") })Then each endpoint becomes:
- g.Attribute("instance_id", g.String, func() { - g.Description("The ID of the instance to restart.") - g.Example("68f50878-44d2-4524-a823-e31bd478706d-n1-689qacsi") - g.MinLength(1) - g.MaxLength(63) - }) + g.Attribute("instance_id", InstanceID, func() { + g.Description("The ID of the instance to restart.") + })Remember to run
make -C api generateafter any design change.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@api/apiv1/design/api.go` around lines 731 - 741, The repeated inline instance ID constraints should be consolidated into a shared InstanceID type in common.go: define a g.Type named InstanceID (string) with Description, MinLength(1), MaxLength(63) and Example, then replace the inline g.String + MinLength/MaxLength usages in the restart-instance, stop-instance, and start-instance payloads (and the candidate_instance_id declaration) to reference InstanceID instead of duplicating constraints; ensure Identifier remains unchanged if needed, update usages to the new InstanceID symbol, and run make -C api generate after the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@api/apiv1/design/api.go`:
- Around line 731-741: The repeated inline instance ID constraints should be
consolidated into a shared InstanceID type in common.go: define a g.Type named
InstanceID (string) with Description, MinLength(1), MaxLength(63) and Example,
then replace the inline g.String + MinLength/MaxLength usages in the
restart-instance, stop-instance, and start-instance payloads (and the
candidate_instance_id declaration) to reference InstanceID instead of
duplicating constraints; ensure Identifier remains unchanged if needed, update
usages to the new InstanceID symbol, and run make -C api generate after the
change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 113820c7-b850-41f4-844e-1fd2f141d759
⛔ Files ignored due to path filters (10)
api/apiv1/gen/control_plane/service.gois excluded by!**/gen/**api/apiv1/gen/http/cli/control_plane/cli.gois excluded by!**/gen/**api/apiv1/gen/http/control_plane/client/cli.gois excluded by!**/gen/**api/apiv1/gen/http/control_plane/client/encode_decode.gois excluded by!**/gen/**api/apiv1/gen/http/control_plane/server/encode_decode.gois excluded by!**/gen/**api/apiv1/gen/http/control_plane/server/types.gois excluded by!**/gen/**api/apiv1/gen/http/openapi.jsonis excluded by!**/gen/**api/apiv1/gen/http/openapi.yamlis excluded by!**/gen/**api/apiv1/gen/http/openapi3.jsonis excluded by!**/gen/**api/apiv1/gen/http/openapi3.yamlis excluded by!**/gen/**
📒 Files selected for processing (1)
api/apiv1/design/api.go
c393827 to
9e14940
Compare
Fixes an issue where valid instance IDs are rejected by our API validation. Instance IDs are an aggregate that includes database ID, node name, and a hash of the host ID. When the database ID is the maximum allowable length for an Identifier, its instance IDs will exceed the maximum length for an Identifier. This commit switches to using strings with longer limits to avoid this issue.
9e14940 to
6528c9d
Compare
Fixes an issue where valid instance IDs are rejected by our API validation. Instance IDs are an aggregate that includes database ID, node name, and a hash of the host ID. When the database ID is the maximum allowable length for an Identifier, its instance IDs will exceed the maximum length for an Identifier. This commit switches to using strings with longer limits to avoid this issue.
Summary
Fixes an issue where valid instance IDs are rejected by our API validation. Instance IDs are an aggregate that includes database ID, node name, and a hash of the host ID. When the database ID is the maximum allowable length for an Identifier, its instance IDs will exceed the maximum length for an Identifier. This commit switches to using strings with longer limits to avoid this issue.
Testing
This PR fixes this test case: