perf: reduce deployment targets endpoing response size to reduce memory usage#868
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughRefactors Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
apps/workspace-engine/svc/http/server/openapi/release_targets/getters.go (1)
158-162:messagecan stay optional here.The slimmed payload still writes
messagefor everylatestJob, even though the new schema makes that field optional. BuildingjobHwithoutmessageby default and only adding it when a message exists would trim the response a bit further.🤖 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 158 - 162, The current construction of jobH always includes "message" even when empty; update the code that builds jobH (the map for lj / latestJob) to omit the "message" key by default and only set it when lj.JobMessage is present (e.g., check lj.JobMessage != "" or lj.JobMessage.Valid / non-nil depending on the type) so the JSON payload only contains "message" when there is a value; keep other fields (id, status, metadata, createdAt) unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/workspace-engine/oapi/spec/schemas/release_targets.jsonnet`:
- Around line 21-38: The change narrows the published contract by replacing the
full Job reference with an inline partial object for latestJob, removing fields
consumers rely on (e.g., startedAt, completedAt); restore the original contract
shape by using allOf with openapi.schemaRef('Job') combined with any additional
constraints instead of redefining properties inline, ensuring latestJob still
exposes the full Job schema (so callers like DeploymentSummaries.tsx that read
latestJob?.completedAt keep working) or explicitly add back every removed Job
field if you truly intend a breaking change and update all consumers
accordingly.
---
Nitpick comments:
In `@apps/workspace-engine/svc/http/server/openapi/release_targets/getters.go`:
- Around line 158-162: The current construction of jobH always includes
"message" even when empty; update the code that builds jobH (the map for lj /
latestJob) to omit the "message" key by default and only set it when
lj.JobMessage is present (e.g., check lj.JobMessage != "" or lj.JobMessage.Valid
/ non-nil depending on the type) so the JSON payload only contains "message"
when there is a value; keep other fields (id, status, metadata, createdAt)
unchanged.
🪄 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: d6045f73-065f-47a7-96ad-eb558b4081b6
📒 Files selected for processing (7)
apps/workspace-engine/oapi/openapi.jsonapps/workspace-engine/oapi/spec/schemas/release_targets.jsonnetapps/workspace-engine/pkg/db/queries/release_targets.sqlapps/workspace-engine/pkg/db/release_targets.sql.goapps/workspace-engine/pkg/oapi/oapi.gen.goapps/workspace-engine/svc/http/server/openapi/release_targets/getters.gopackages/workspace-engine-sdk/src/schema.ts
💤 Files with no reviewable changes (1)
- apps/workspace-engine/pkg/db/queries/release_targets.sql
| latestJob: { | ||
| nullable: true, | ||
| allOf: [ | ||
| openapi.schemaRef('Job'), | ||
| { | ||
| type: 'object', | ||
| required: ['id', 'status', 'createdAt', 'metadata', 'verifications'], | ||
| properties: { | ||
| id: { type: 'string' }, | ||
| status: openapi.schemaRef('JobStatus'), | ||
| message: { type: 'string' }, | ||
| createdAt: { type: 'string', format: 'date-time' }, | ||
| metadata: { | ||
| type: 'object', | ||
| required: ['verifications'], | ||
| properties: { | ||
| verifications: { | ||
| type: 'array', | ||
| items: openapi.schemaRef('JobVerification'), | ||
| }, | ||
| }, | ||
| additionalProperties: { type: 'string' }, | ||
| }, | ||
| ], | ||
| verifications: { | ||
| type: 'array', | ||
| items: openapi.schemaRef('JobVerification'), | ||
| }, | ||
| }, |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# First, let's verify the file exists and check its structure
git ls-files | grep -E "(release_targets|Job)" | head -20Repository: ctrlplanedev/ctrlplane
Length of output: 897
🏁 Script executed:
# Check the file at the specified location
cat -n "apps/workspace-engine/oapi/spec/schemas/release_targets.jsonnet" | head -50Repository: ctrlplanedev/ctrlplane
Length of output: 1702
🏁 Script executed:
# Search for Job schema definition
fd -t f "\.jsonnet$" apps/workspace-engine/oapi/spec/schemas/ -x grep -l "Job" {}Repository: ctrlplanedev/ctrlplane
Length of output: 527
🏁 Script executed:
# Let's examine the Job schema to see what fields it has
cat -n "apps/workspace-engine/oapi/spec/schemas/jobs.jsonnet"Repository: ctrlplanedev/ctrlplane
Length of output: 6790
🏁 Script executed:
# Check git history to see what latestJob was before this change
cd apps/workspace-engine/oapi/spec/schemas && git log --oneline -20 release_targets.jsonnetRepository: ctrlplanedev/ctrlplane
Length of output: 78
🏁 Script executed:
# Get the diff for this specific file to see what changed
cd apps/workspace-engine/oapi/spec/schemas && git show HEAD:release_targets.jsonnet 2>/dev/null | head -50 || echo "Cannot get previous version"Repository: ctrlplanedev/ctrlplane
Length of output: 48
🏁 Script executed:
# Search for references to latestJob in the codebase
rg "latestJob" --type ts --type go --type jsonnet -B2 -A2Repository: ctrlplanedev/ctrlplane
Length of output: 97
🏁 Script executed:
# Let's search for latestJob references more broadly
rg "latestJob" -A3 -B3Repository: ctrlplanedev/ctrlplane
Length of output: 49409
🏁 Script executed:
# Check the git diff to see what changed in this file
cd apps/workspace-engine/oapi/spec/schemas && git diff HEAD~1 release_targets.jsonnet 2>/dev/null || git log --all --oneline release_targets.jsonnet | head -10Repository: ctrlplanedev/ctrlplane
Length of output: 157
🏁 Script executed:
# Let's look at the generated Go types to see if they match
find apps/workspace-engine -name "*.go" -type f | xargs grep -l "ReleaseTargetItem" | head -3Repository: ctrlplanedev/ctrlplane
Length of output: 108
🏁 Script executed:
# Check if there are TypeScript SDK files generated from these schemas
find apps -name "*.ts" -type f | xargs grep -l "ReleaseTargetItem\|latestJob" | head -5Repository: ctrlplanedev/ctrlplane
Length of output: 313
🏁 Script executed:
# Let's verify that DeploymentSummaries.tsx actually uses completedAt and would break
grep -n "completedAt" "apps/web/app/routes/ws/environments/_components/DeploymentSummaries.tsx"Repository: ctrlplanedev/ctrlplane
Length of output: 177
🏁 Script executed:
# Check the git diff for the specific commit to see if this is intentional
cd apps/workspace-engine/oapi/spec/schemas && git show af5f8f12:release_targets.jsonnet | head -50Repository: ctrlplanedev/ctrlplane
Length of output: 321
🏁 Script executed:
# Check the previous version of the file
cd apps/workspace-engine/oapi/spec/schemas && git show af5f8f12:apps/workspace-engine/oapi/spec/schemas/release_targets.jsonnet | head -50Repository: ctrlplanedev/ctrlplane
Length of output: 1186
🏁 Script executed:
# Check the current HEAD against the previous commit to see what changed
git diff af5f8f12 HEAD -- apps/workspace-engine/oapi/spec/schemas/release_targets.jsonnet | head -100Repository: ctrlplanedev/ctrlplane
Length of output: 1484
This narrows a published contract.
latestJob is being changed from a full Job reference to an inline partial object. Previously it used allOf: [openapi.schemaRef('Job'), {...}], but now it explicitly defines only id, status, message, createdAt, metadata, and verifications. This removes access to fields like startedAt, completedAt, updatedAt, jobAgentId, jobAgentConfig, releaseId, workflowJobId, and others.
Existing code already uses removed fields (e.g., DeploymentSummaries.tsx accesses latestJob?.completedAt on line 96), which will break with this schema change. Treat this as an explicit breaking change and verify all consumers are updated, or revert to the allOf approach that preserves the full Job contract.
🤖 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
21 - 38, The change narrows the published contract by replacing the full Job
reference with an inline partial object for latestJob, removing fields consumers
rely on (e.g., startedAt, completedAt); restore the original contract shape by
using allOf with openapi.schemaRef('Job') combined with any additional
constraints instead of redefining properties inline, ensuring latestJob still
exposes the full Job schema (so callers like DeploymentSummaries.tsx that read
latestJob?.completedAt keep working) or explicitly add back every removed Job
field if you truly intend a breaking change and update all consumers
accordingly.
Summary by CodeRabbit