Skip to content

feat: add app update v3 endpoint - #4768

Merged
borosr merged 4 commits into
mainfrom
feat/v3-app-update
Jul 22, 2026
Merged

borosr merged 4 commits into
mainfrom
feat/v3-app-update

Conversation

@borosr

@borosr borosr commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • Added an “Update installed app” API endpoint: PUT /openmeter/apps/{appId}.
    • Supports updating installed app configurations for Stripe, Sandbox, and External Invoicing (name, description, labels, plus app-specific settings).
    • Updated the JavaScript and Go SDKs to expose the new operation with typed polymorphic update requests.
  • Enhancements
    • Improved label-to-metadata conversion to be null-safe when labels are unset.

Greptile Summary

This PR adds an API for updating installed apps. The main changes are:

  • A new PUT /openmeter/apps/{appId} endpoint.
  • Typed update requests for Stripe, Sandbox, and External Invoicing apps.
  • Generated JavaScript and Go SDK support.
  • Null-safe label-to-metadata conversion.

Confidence Score: 5/5

The follow-up changes look safe to merge.

  • No new blocking issue qualifies for a separate follow-up comment.
  • The generated API and SDK surfaces remain aligned with the endpoint.

Important Files Changed

Filename Overview
api/v3/handlers/apps/update_app.go Adds request parsing, variant conversion, validation errors, and service dispatch for app updates.
api/spec/packages/aip/src/apps/app.tsp Defines the discriminated update request model for supported app types.
api/spec/packages/aip/src/apps/operations.tsp Defines the new internal update operation and response contract.
api/v3/client/models_apps.go Adds generated Go SDK models and tagged-union helpers for app updates.
api/spec/packages/aip-client-javascript/src/funcs/apps.ts Adds the generated JavaScript SDK function for updating installed apps.

Reviews (5): Last reviewed commit: "fix: error handling comment" | Re-trigger Greptile

Context used (3)

  • Context used - CLAUDE.md (source)
  • Context used - AGENTS.md (source)
  • Context used - api/spec/AGENTS.md (source)

@borosr
borosr requested a review from a team as a code owner July 21, 2026 13:51
@borosr borosr self-assigned this Jul 21, 2026
@coderabbitai

coderabbitai Bot commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a PUT /openmeter/apps/{appId} endpoint for updating Stripe, Sandbox, and External Invoicing apps, including API contracts, server handling, generated bindings, Go client support, and JavaScript SDK support.

Changes

Installed app update

Layer / File(s) Summary
Update contract and endpoint
api/spec/.../aip/src/apps/*
Adds a discriminated update request for three app types, exposes the update operation, makes the type discriminator update-visible, and marks API keys as secret.
Generated API and routing contract
api/v3/api.gen.go
Adds generated request unions, server interfaces, middleware, Chi routing, and Swagger data for the update endpoint.
Server update handling
api/v3/handlers/apps/*, api/v3/server/routes.go, api/v3/labels/convert.go
Decodes update requests, maps type-specific configuration and labels, calls the app service, and returns the updated app.
Go and JavaScript client surfaces
api/v3/client/*, api/spec/packages/aip-client-javascript/*
Adds typed request models, serialization and validation, HTTP client methods, SDK wiring, exports, and operation documentation.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

Suggested labels: area/api

Suggested reviewers: tothandras, rolosp, chrisgacsal

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
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding a v3 app update endpoint.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/v3-app-update

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.

@borosr
borosr requested review from rolosp and tothandras July 21, 2026 13:52
@borosr borosr added kind/feature New feature or request release-note/feature Release note: Exciting New Features labels Jul 21, 2026
Comment thread api/v3/handlers/apps/update_app.go Resolved
Comment thread api/spec/packages/aip/src/apps/app.tsp Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
api/v3/handlers/apps/update_app.go (2)

153-158: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Rename helper to align with naming conventions.

Since this function converts an API representation into a domain model, consider renaming it to FromAPILabels or MapAPILabelsToMetadata to 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 win

Extract 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

📥 Commits

Reviewing files that changed from the base of the PR and between 59287dd and fb88a62.

⛔ Files ignored due to path filters (1)
  • api/v3/openapi.yaml is excluded by !**/openapi.yaml
📒 Files selected for processing (17)
  • api/spec/packages/aip-client-javascript/README.md
  • api/spec/packages/aip-client-javascript/src/funcs/apps.ts
  • api/spec/packages/aip-client-javascript/src/index.ts
  • api/spec/packages/aip-client-javascript/src/models/operations/apps.ts
  • api/spec/packages/aip-client-javascript/src/models/schemas.ts
  • api/spec/packages/aip-client-javascript/src/models/types.ts
  • api/spec/packages/aip-client-javascript/src/sdk/internal.ts
  • api/spec/packages/aip/src/apps/app.tsp
  • api/spec/packages/aip/src/apps/catalog.tsp
  • api/spec/packages/aip/src/apps/operations.tsp
  • api/v3/api.gen.go
  • api/v3/client/README.md
  • api/v3/client/apps.go
  • api/v3/client/models_apps.go
  • api/v3/handlers/apps/handler.go
  • api/v3/handlers/apps/update_app.go
  • api/v3/server/routes.go

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
api/v3/labels/convert.go (1)

109-117: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider returning a nil pointer alongside the validation error.

When ToMetadataAnnotations returns an error, ToMetadataPtr still returns a (possibly partial) non-nil *map[string]string. Current callers discard it on error so there's no live bug, but returning nil on error would remove the risk for any future caller that forgets to check err.

♻️ 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

📥 Commits

Reviewing files that changed from the base of the PR and between fb88a62 and 3fe5812.

📒 Files selected for processing (2)
  • api/v3/handlers/apps/update_app.go
  • api/v3/labels/convert.go

@borosr
borosr force-pushed the feat/v3-app-update branch from 3fe5812 to 0732945 Compare July 21, 2026 15:53
@borosr
borosr requested a review from chrisgacsal July 21, 2026 15:53
@borosr
borosr force-pushed the feat/v3-app-update branch from 0732945 to dd926ca Compare July 22, 2026 03:14

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
api/v3/handlers/apps/update_app.go (1)

28-167: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider 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 switch arm repeats the same shape: parse the variant, run labels.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

📥 Commits

Reviewing files that changed from the base of the PR and between 0732945 and dd926ca.

⛔ Files ignored due to path filters (1)
  • api/v3/openapi.yaml is excluded by !**/openapi.yaml
📒 Files selected for processing (18)
  • api/spec/packages/aip-client-javascript/README.md
  • api/spec/packages/aip-client-javascript/src/funcs/apps.ts
  • api/spec/packages/aip-client-javascript/src/index.ts
  • api/spec/packages/aip-client-javascript/src/models/operations/apps.ts
  • api/spec/packages/aip-client-javascript/src/models/schemas.ts
  • api/spec/packages/aip-client-javascript/src/models/types.ts
  • api/spec/packages/aip-client-javascript/src/sdk/internal.ts
  • api/spec/packages/aip/src/apps/app.tsp
  • api/spec/packages/aip/src/apps/catalog.tsp
  • api/spec/packages/aip/src/apps/operations.tsp
  • api/v3/api.gen.go
  • api/v3/client/README.md
  • api/v3/client/apps.go
  • api/v3/client/models_apps.go
  • api/v3/handlers/apps/handler.go
  • api/v3/handlers/apps/update_app.go
  • api/v3/labels/convert.go
  • api/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

Comment thread api/v3/handlers/apps/update_app.go Resolved
@borosr
borosr merged commit aba3ec4 into main Jul 22, 2026
30 checks passed
@borosr
borosr deleted the feat/v3-app-update branch July 22, 2026 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature New feature or request release-note/feature Release note: Exciting New Features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants