Repository navigation
feat: add app update v3 endpoint - #4768
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds a ChangesInstalled app update
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant Client
participant ChiRouter
participant UpdateAppHandler
participant AppService
Client->>ChiRouter: PUT /openmeter/apps/{appId}
ChiRouter->>UpdateAppHandler: dispatch UpdateApp
UpdateAppHandler->>AppService: UpdateApp(UpdateAppRequest)
AppService-->>UpdateAppHandler: updated app
UpdateAppHandler-->>Client: JSON BillingApp response
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
api/v3/handlers/apps/update_app.go (2)
153-158: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRename helper to align with naming conventions.
Since this function converts an API representation into a domain model, consider renaming it to
FromAPILabelsorMapAPILabelsToMetadatato better align with our project conventions!As per coding guidelines: "Use FromAPI..., ToAPI..., FromDB..., and ToDB... naming for domain/API/DB conversion functions, and use map/mapped terminology for representation translation."
♻️ Proposed refactor
-// metadataFromAPILabels converts the API labels of an app update request into the +// FromAPILabels converts the API labels of an app update request into the // domain Metadata pointer expected by app.UpdateAppInput. Update is a full replace // (mirrors the v1 PUT semantics), so a nil labels field is passed through as a nil // pointer, which the adapter's SetOrClearMetadata interprets as "clear metadata" - // omitting "labels" in the request body removes any previously configured labels. -func metadataFromAPILabels(l *api.Labels) (*map[string]string, error) { +func FromAPILabels(l *api.Labels) (*map[string]string, error) {🤖 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/v3/handlers/apps/update_app.go` around lines 153 - 158, Rename metadataFromAPILabels to FromAPILabels, updating every call site and any related references while preserving its existing nil-label handling and conversion behavior.Source: Coding guidelines
28-135: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExtract request decoding and domain mapping.
This closure handles quite a bit of branching, validation, and domain conversion. To keep the handler wiring clean and easier to follow, how about extracting this logic into a named helper method (like
decodeUpdateAppRequest) on the handler?As per coding guidelines: "Do not hide non-trivial branching, validation, persistence mapping, or domain conversion inside local closures; use a named helper near the call site."
🤖 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/v3/handlers/apps/update_app.go` around lines 28 - 135, The anonymous request-decoding closure should be extracted into a named handler method, such as decodeUpdateAppRequest. Move its namespace resolution, body parsing, discriminator validation, type-specific conversion, and error handling into that method, preserving the existing UpdateAppRequest results and validation behavior; update the handler wiring to call the named helper instead.Source: Coding guidelines
🤖 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/v3/handlers/apps/update_app.go`:
- Around line 153-158: Rename metadataFromAPILabels to FromAPILabels, updating
every call site and any related references while preserving its existing
nil-label handling and conversion behavior.
- Around line 28-135: The anonymous request-decoding closure should be extracted
into a named handler method, such as decodeUpdateAppRequest. Move its namespace
resolution, body parsing, discriminator validation, type-specific conversion,
and error handling into that method, preserving the existing UpdateAppRequest
results and validation behavior; update the handler wiring to call the named
helper instead.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 9cad30a7-eef1-4bcf-b985-4bc8fa9768d5
⛔ Files ignored due to path filters (1)
api/v3/openapi.yamlis excluded by!**/openapi.yaml
📒 Files selected for processing (17)
api/spec/packages/aip-client-javascript/README.mdapi/spec/packages/aip-client-javascript/src/funcs/apps.tsapi/spec/packages/aip-client-javascript/src/index.tsapi/spec/packages/aip-client-javascript/src/models/operations/apps.tsapi/spec/packages/aip-client-javascript/src/models/schemas.tsapi/spec/packages/aip-client-javascript/src/models/types.tsapi/spec/packages/aip-client-javascript/src/sdk/internal.tsapi/spec/packages/aip/src/apps/app.tspapi/spec/packages/aip/src/apps/catalog.tspapi/spec/packages/aip/src/apps/operations.tspapi/v3/api.gen.goapi/v3/client/README.mdapi/v3/client/apps.goapi/v3/client/models_apps.goapi/v3/handlers/apps/handler.goapi/v3/handlers/apps/update_app.goapi/v3/server/routes.go
There was a problem hiding this comment.
🧹 Nitpick comments (1)
api/v3/labels/convert.go (1)
109-117: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider returning a nil pointer alongside the validation error.
When
ToMetadataAnnotationsreturns an error,ToMetadataPtrstill returns a (possibly partial) non-nil*map[string]string. Current callers discard it on error so there's no live bug, but returningnilon error would remove the risk for any future caller that forgets to checkerr.♻️ Optional defensive tweak
m, err := ToMetadataAnnotations(labels) + if err != nil { + return nil, err + } return lo.ToPtr(map[string]string(m.Metadata)), err🤖 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/v3/labels/convert.go` around lines 109 - 117, Update ToMetadataPtr to return a nil metadata pointer whenever ToMetadataAnnotations returns an error, while preserving the existing successful conversion and nil-label behavior. Check err before constructing or returning the map pointer.
🤖 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/v3/labels/convert.go`:
- Around line 109-117: Update ToMetadataPtr to return a nil metadata pointer
whenever ToMetadataAnnotations returns an error, while preserving the existing
successful conversion and nil-label behavior. Check err before constructing or
returning the map pointer.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 8c9eee7e-b3c6-4b6d-b3c7-48ff599e8d5f
📒 Files selected for processing (2)
api/v3/handlers/apps/update_app.goapi/v3/labels/convert.go
3fe5812 to
0732945
Compare
0732945 to
dd926ca
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
api/v3/handlers/apps/update_app.go (1)
28-167: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider lifting the decode logic into a named helper to trim the repetition.
The request-decoding closure carries a fair bit of branching and domain conversion, and each
switcharm repeats the same shape: parse the variant, runlabels.ToMetadataPtr, wrap the error, build the request. Pulling this into a named method like(h *handler) decodeUpdateAppRequest(ctx, r, appId)(with a small helper for the label-mapping + error wrapping) would make the handler easier to scan and cut the duplication.As per coding guidelines: "Do not hide non-trivial branching, validation, persistence mapping, or domain conversion inside local closures; use a named helper near the call site."
🤖 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/v3/handlers/apps/update_app.go` around lines 28 - 167, The request-decoding closure contains substantial branching, validation, and repeated variant conversion that should be moved into a named handler method. Extract it as `(h *handler) decodeUpdateAppRequest(ctx, r, appId)` near the call site, preserving namespace resolution, discriminator validation, variant mapping, and error behavior; factor the repeated `labels.ToMetadataPtr` conversion and bad-request wrapping into a small helper.Source: Coding guidelines
🤖 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.
Inline comments:
In `@api/v3/handlers/apps/update_app.go`:
- Around line 164-165: Update the default branch of the app-type switch in
UpdateAppRequest conversion to return the same structured BadRequestError used
by the preceding validation path, rather than a bare fmt.Errorf. Preserve the
unsupported app type context and ensure any valid-but-unhandled BillingAppType
is encoded as HTTP 400.
---
Nitpick comments:
In `@api/v3/handlers/apps/update_app.go`:
- Around line 28-167: The request-decoding closure contains substantial
branching, validation, and repeated variant conversion that should be moved into
a named handler method. Extract it as `(h *handler) decodeUpdateAppRequest(ctx,
r, appId)` near the call site, preserving namespace resolution, discriminator
validation, variant mapping, and error behavior; factor the repeated
`labels.ToMetadataPtr` conversion and bad-request wrapping into a small helper.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f9da2b8f-473e-41ea-a63b-5fdfd982b598
⛔ Files ignored due to path filters (1)
api/v3/openapi.yamlis excluded by!**/openapi.yaml
📒 Files selected for processing (18)
api/spec/packages/aip-client-javascript/README.mdapi/spec/packages/aip-client-javascript/src/funcs/apps.tsapi/spec/packages/aip-client-javascript/src/index.tsapi/spec/packages/aip-client-javascript/src/models/operations/apps.tsapi/spec/packages/aip-client-javascript/src/models/schemas.tsapi/spec/packages/aip-client-javascript/src/models/types.tsapi/spec/packages/aip-client-javascript/src/sdk/internal.tsapi/spec/packages/aip/src/apps/app.tspapi/spec/packages/aip/src/apps/catalog.tspapi/spec/packages/aip/src/apps/operations.tspapi/v3/api.gen.goapi/v3/client/README.mdapi/v3/client/apps.goapi/v3/client/models_apps.goapi/v3/handlers/apps/handler.goapi/v3/handlers/apps/update_app.goapi/v3/labels/convert.goapi/v3/server/routes.go
🚧 Files skipped from review as they are similar to previous changes (12)
- api/v3/handlers/apps/handler.go
- api/spec/packages/aip-client-javascript/src/sdk/internal.ts
- api/spec/packages/aip-client-javascript/README.md
- api/v3/labels/convert.go
- api/spec/packages/aip-client-javascript/src/models/operations/apps.ts
- api/spec/packages/aip/src/apps/app.tsp
- api/v3/client/apps.go
- api/v3/client/README.md
- api/spec/packages/aip-client-javascript/src/index.ts
- api/v3/server/routes.go
- api/v3/client/models_apps.go
- api/spec/packages/aip-client-javascript/src/models/schemas.ts
Summary by CodeRabbit
PUT /openmeter/apps/{appId}.Greptile Summary
This PR adds an API for updating installed apps. The main changes are:
PUT /openmeter/apps/{appId}endpoint.Confidence Score: 5/5
The follow-up changes look safe to merge.
Important Files Changed
Reviews (5): Last reviewed commit: "fix: error handling comment" | Re-trigger Greptile
Context used (3)