Skip to content

perf: slim down release targets server response#869

Merged
adityachoudhari26 merged 1 commit intomainfrom
slim-down-response
Mar 26, 2026
Merged

perf: slim down release targets server response#869
adityachoudhari26 merged 1 commit intomainfrom
slim-down-response

Conversation

@adityachoudhari26
Copy link
Copy Markdown
Member

@adityachoudhari26 adityachoudhari26 commented Mar 26, 2026

Summary by CodeRabbit

Release Notes

  • Refactor
    • Updated release target API response structure to streamline data formats.
    • Version information now includes core identifiers only (id, name, tag).
    • Environment and resource details simplified to essential fields.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 26, 2026

📝 Walkthrough

Walkthrough

Narrowed ReleaseTargetItem schema by inlining environment, resource, currentVersion, and desiredVersion with only essential fields; removed corresponding columns from SQL queries and fields from generated code across database, server, and SDK layers.

Changes

Cohort / File(s) Summary
Schema Definition & Code Generation
apps/workspace-engine/oapi/openapi.json, apps/workspace-engine/oapi/spec/schemas/release_targets.jsonnet
Inlined environment (requires id, name), resource (requires id, name, version, kind, identifier), currentVersion, and desiredVersion (each requires id, name, tag; nullable) instead of referencing shared schema components.
Database Layer
apps/workspace-engine/pkg/db/queries/release_targets.sql, apps/workspace-engine/pkg/db/release_targets.sql.go
Removed columns from ListReleaseTargetsByDeploymentID, ListCurrentVersionsByDeploymentID, and ListVerificationMetricsByJobIDs queries; corresponding struct fields removed from result types (e.g., deployment metadata, resource config, version details).
Generated OpenAPI & HTTP Server
apps/workspace-engine/pkg/oapi/oapi.gen.go, apps/workspace-engine/svc/http/server/openapi/release_targets/getters.go
Updated ReleaseTargetItem struct fields to use inline types; removed nested object fields from response serialization in ListReleaseTargets and buildVerificationsMap.
TypeScript SDK
packages/workspace-engine-sdk/src/schema.ts
Updated ReleaseTargetItem type definitions to inline object shapes for environment, resource, currentVersion, and desiredVersion with restricted property sets.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • PR #690: Modifies Workspace Engine OpenAPI shapes for release targets and deployment-version job payloads; overlapping schema changes.
  • PR #610: Narrows fields on ReleaseTargetItem (resource/environment/currentVersion/desiredVersion), directly affecting the payload shape used by dependent code.
  • PR #867: Modifies the same release-targets code paths including ReleaseTargetItem OpenAPI schema and sqlc queries/generated structs.

Suggested reviewers

  • jsbroks

Poem

A rabbit hops through schemas neat,
Trimming fields to make things fleet,
Version, environment, resource too—
Inlined shapes, now streamlined through! 🐰✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'perf: slim down release targets server response' accurately reflects the main change, which involves removing unnecessary fields from the ReleaseTargetItem schema and associated database queries to optimize response payload size and performance.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 slim-down-response

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 and usage tips.

Copy link
Copy Markdown
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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/workspace-engine/pkg/db/queries/release_targets.sql (1)

81-102: ⚠️ Potential issue | 🟠 Major

intervalSeconds is still required by the published verification schema.

This query no longer returns jvm.interval_seconds, but latestJob.verifications[].metrics[] is still typed as VerificationMetricStatus in apps/workspace-engine/oapi/openapi.json and packages/workspace-engine-sdk/src/schema.ts, where intervalSeconds remains required. The endpoint will now emit payloads that don't satisfy the generated contract. Keep selecting/serializing that field, or slim the verification schemas and regenerate clients in the same change.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/workspace-engine/pkg/db/queries/release_targets.sql` around lines 81 -
102, The SQL query ListVerificationMetricsByJobIDs removed the
jvm.interval_seconds column but consumers still expect
VerificationMetricStatus.intervalSeconds; restore the column in the SELECT
(e.g., select jvm.interval_seconds AS metric_interval_seconds or the original
name used by serialization) so the query result matches the openapi/schema
types, or if you intend to remove it, update the VerificationMetricStatus schema
in the OpenAPI (apps/workspace-engine/oapi/openapi.json) and regenerate the SDK
(packages/workspace-engine-sdk) to keep API contract and clients in sync; locate
the query named ListVerificationMetricsByJobIDs and adjust the SELECT or the
schema accordingly.
🧹 Nitpick comments (2)
apps/workspace-engine/svc/http/server/openapi/release_targets/getters.go (1)

87-146: Prefer the generated ReleaseTargetItem type over ad-hoc gin.H maps.

This block is manually re-declaring the response contract, so shape drift can slip through without a compiler failure. Building the generated type here would make future nested-field removals/additions much harder to miss.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/workspace-engine/svc/http/server/openapi/release_targets/getters.go`
around lines 87 - 146, Replace the ad-hoc gin.H maps in the loop that builds
items (where ReleaseTargetResult is constructed from rows, using
currentVersionMap, latestJobMap and verificationsMap) with the generated
ReleaseTargetItem/related types from the OpenAPI models: instantiate
ReleaseTargetItem (and nested types for Environment, Resource, DesiredVersion,
CurrentVersion, LatestJob, Verifications) and assign strongly-typed fields
instead of gin.H; populate fields using the existing row.*, cv.* and lj.* values
(use json.RawMessage for JobMetadata and proper zero/nil handling when
DesiredVersionID == nilUUID or verificationsMap has no entry), keep the same key
construction and map lookups but return the typed ReleaseTargetResult items so
the response shape matches the generated contract.
apps/workspace-engine/oapi/spec/schemas/release_targets.jsonnet (1)

17-55: Reuse the existing summary components instead of inlining copies.

These shapes already exist as EnvironmentSummary, ResourceSummary, and VersionSummary. Referencing them here would avoid the anonymous structs now emitted in apps/workspace-engine/pkg/oapi/oapi.gen.go and reduce the chance that one copy changes without the others.

♻️ Suggested cleanup
-      environment: {
-        type: 'object',
-        required: ['id', 'name'],
-        properties: {
-          id: { type: 'string' },
-          name: { type: 'string' },
-        },
-      },
+      environment: openapi.schemaRef('EnvironmentSummary'),

-      resource: {
-        type: 'object',
-        required: ['id', 'name', 'version', 'kind', 'identifier'],
-        properties: {
-          id: { type: 'string' },
-          name: { type: 'string' },
-          version: { type: 'string' },
-          kind: { type: 'string' },
-          identifier: { type: 'string' },
-        },
-      },
+      resource: openapi.schemaRef('ResourceSummary'),

-      desiredVersion: {
-        nullable: true,
-        type: 'object',
-        required: ['id', 'name', 'tag'],
-        properties: {
-          id: { type: 'string' },
-          name: { type: 'string' },
-          tag: { type: 'string' },
-        },
-      },
+      desiredVersion: openapi.schemaRef('VersionSummary', nullable=true),

-      currentVersion: {
-        nullable: true,
-        type: 'object',
-        required: ['id', 'name', 'tag'],
-        properties: {
-          id: { type: 'string' },
-          name: { type: 'string' },
-          tag: { type: 'string' },
-        },
-      },
+      currentVersion: openapi.schemaRef('VersionSummary', nullable=true),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/workspace-engine/oapi/spec/schemas/release_targets.jsonnet` around lines
17 - 55, Replace the inline anonymous object schemas for environment, resource,
desiredVersion, and currentVersion with references to the existing summary
components: use EnvironmentSummary for environment, ResourceSummary for
resource, and VersionSummary for desiredVersion and currentVersion (i.e., swap
the explicit type/required/properties blocks under the keys environment,
resource, desiredVersion, currentVersion to $ref entries that point to the
existing components). This will prevent duplicate emitted structs and keep
generated types consistent across EnvironmentSummary, ResourceSummary, and
VersionSummary.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@apps/workspace-engine/pkg/db/queries/release_targets.sql`:
- Around line 81-102: The SQL query ListVerificationMetricsByJobIDs removed the
jvm.interval_seconds column but consumers still expect
VerificationMetricStatus.intervalSeconds; restore the column in the SELECT
(e.g., select jvm.interval_seconds AS metric_interval_seconds or the original
name used by serialization) so the query result matches the openapi/schema
types, or if you intend to remove it, update the VerificationMetricStatus schema
in the OpenAPI (apps/workspace-engine/oapi/openapi.json) and regenerate the SDK
(packages/workspace-engine-sdk) to keep API contract and clients in sync; locate
the query named ListVerificationMetricsByJobIDs and adjust the SELECT or the
schema accordingly.

---

Nitpick comments:
In `@apps/workspace-engine/oapi/spec/schemas/release_targets.jsonnet`:
- Around line 17-55: Replace the inline anonymous object schemas for
environment, resource, desiredVersion, and currentVersion with references to the
existing summary components: use EnvironmentSummary for environment,
ResourceSummary for resource, and VersionSummary for desiredVersion and
currentVersion (i.e., swap the explicit type/required/properties blocks under
the keys environment, resource, desiredVersion, currentVersion to $ref entries
that point to the existing components). This will prevent duplicate emitted
structs and keep generated types consistent across EnvironmentSummary,
ResourceSummary, and VersionSummary.

In `@apps/workspace-engine/svc/http/server/openapi/release_targets/getters.go`:
- Around line 87-146: Replace the ad-hoc gin.H maps in the loop that builds
items (where ReleaseTargetResult is constructed from rows, using
currentVersionMap, latestJobMap and verificationsMap) with the generated
ReleaseTargetItem/related types from the OpenAPI models: instantiate
ReleaseTargetItem (and nested types for Environment, Resource, DesiredVersion,
CurrentVersion, LatestJob, Verifications) and assign strongly-typed fields
instead of gin.H; populate fields using the existing row.*, cv.* and lj.* values
(use json.RawMessage for JobMetadata and proper zero/nil handling when
DesiredVersionID == nilUUID or verificationsMap has no entry), keep the same key
construction and map lookups but return the typed ReleaseTargetResult items so
the response shape matches the generated contract.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 33c6ea3b-6b1a-4bf5-b7da-dd2fa5cf870f

📥 Commits

Reviewing files that changed from the base of the PR and between 6d6aa92 and 91e3a36.

📒 Files selected for processing (7)
  • apps/workspace-engine/oapi/openapi.json
  • apps/workspace-engine/oapi/spec/schemas/release_targets.jsonnet
  • apps/workspace-engine/pkg/db/queries/release_targets.sql
  • apps/workspace-engine/pkg/db/release_targets.sql.go
  • apps/workspace-engine/pkg/oapi/oapi.gen.go
  • apps/workspace-engine/svc/http/server/openapi/release_targets/getters.go
  • packages/workspace-engine-sdk/src/schema.ts

@adityachoudhari26 adityachoudhari26 merged commit b203d35 into main Mar 26, 2026
11 checks passed
@adityachoudhari26 adityachoudhari26 deleted the slim-down-response branch March 26, 2026 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant