Skip to content

chore: jobAgentSelector is required field in deployment schema#940

Merged
adityachoudhari26 merged 1 commit intomainfrom
make-selector-required
Apr 8, 2026
Merged

chore: jobAgentSelector is required field in deployment schema#940
adityachoudhari26 merged 1 commit intomainfrom
make-selector-required

Conversation

@adityachoudhari26
Copy link
Copy Markdown
Member

@adityachoudhari26 adityachoudhari26 commented Apr 8, 2026

Resolves #917

Summary by CodeRabbit

Release Notes

  • New Features

    • Added resource search functionality via new API endpoint for filtering and querying resources by identifiers, kinds, metadata, providers, and more.
  • Breaking Changes

    • The jobAgentSelector field is now required for deployment configurations and must be provided in all deployment requests.

Copilot AI review requested due to automatic review settings April 8, 2026 21:26
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 8, 2026

📝 Walkthrough

Walkthrough

The PR converts Deployment.JobAgentSelector from an optional pointer field (*string) to a required string field across OpenAPI schemas, generated types, and controller implementations. Additionally, a new REST endpoint for resource search is introduced with filtering, sorting, and pagination capabilities.

Changes

Cohort / File(s) Summary
Deployment Schema — JobAgentSelector Required
apps/api/openapi/openapi.json, apps/api/openapi/schemas/deployments.jsonnet, apps/api/src/types/openapi.ts, apps/workspace-engine/oapi/openapi.json, apps/workspace-engine/oapi/spec/schemas/deployments.jsonnet, packages/workspace-engine-sdk/src/schema.ts
Updated OpenAPI and generated TypeScript schemas to mark jobAgentSelector as a required field (no longer optional) in the Deployment schema across all service definitions.
Go Struct & Type Updates
apps/workspace-engine/pkg/oapi/oapi.gen.go
Changed JobAgentSelector field from optional pointer (*string with omitempty) to required string value (string), altering JSON serialization behavior.
Database Conversion & Selector Logic
apps/workspace-engine/pkg/db/convert.go, apps/workspace-engine/svc/controllers/deploymentplan/controller.go, apps/workspace-engine/svc/controllers/jobdispatch/reconcile.go, apps/workspace-engine/svc/controllers/jobeligibility/reconcile.go, apps/workspace-engine/test/controllers/harness/pipeline.go
Updated ToOapiDeployment and controller code to pass JobAgentSelector as a direct string value instead of dereferencing a pointer; removed nil checks and updated selector matching calls accordingly.
Test Fixtures & Helpers
apps/workspace-engine/svc/controllers/deploymentplan/controller_test.go, apps/workspace-engine/svc/controllers/jobdispatch/reconcile_test.go, apps/workspace-engine/svc/controllers/jobeligibility/reconcile_test.go
Updated test construction of oapi.Deployment.JobAgentSelector to use direct string values instead of pointer references; adjusted empty selector test cases.
Resource Search Endpoint
apps/web/app/api/openapi.ts
Added new POST /v1/workspaces/{workspaceId}/resources/search endpoint with ListResourcesFilters schema supporting filtering by identifiers, kinds, metadata, provider IDs, query, and sorting/pagination options.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related issues

  • refactor: deployment agent selectors #914: Directly implements the selector-based deployment agent model, touching the same Deployment.jobAgentSelector field, serialization types, DB conversion, and dispatch/matching code paths.

Possibly related PRs

Suggested reviewers

  • jsbroks
  • mleonidas

🐰 A selector springs to life, no pointer in sight,
String values now required, the schema burns bright,
Through controllers and tests, the changes take flight,
While resources can search with filters so right! 🔍✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 23.08% 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 accurately describes the primary change: making jobAgentSelector a required field across the Deployment schema in multiple files.

✏️ 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 make-selector-required

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.

🧹 Nitpick comments (1)
apps/workspace-engine/svc/controllers/jobeligibility/reconcile_test.go (1)

1172-1183: Consider removing or renaming this duplicate test.

With JobAgentSelector now a string instead of *string, there's no distinct "nil" case—only empty string. This test (TestReconcile_NilJobAgentSelector_CreatesFailureJob) is now identical to TestReconcile_NoJobAgentSelector_CreatesFailureJob above (lines 1159–1170): both set JobAgentSelector = "" and assert the same behavior.

Either remove this test as a duplicate, or rename it to test a meaningfully different scenario if one exists.

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

In `@apps/workspace-engine/svc/controllers/jobeligibility/reconcile_test.go`
around lines 1172 - 1183, The test
TestReconcile_NilJobAgentSelector_CreatesFailureJob is now a duplicate of
TestReconcile_NoJobAgentSelector_CreatesFailureJob because JobAgentSelector is a
string (no nil case); remove TestReconcile_NilJobAgentSelector_CreatesFailureJob
or rename and change it to cover a distinct scenario (e.g., an invalid non-empty
selector value or whitespace-only selector) by updating the test body that
manipulates getter.deployment.JobAgentSelector and the corresponding assertions
in Reconcile to reflect the new behavior being tested.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@apps/workspace-engine/svc/controllers/jobeligibility/reconcile_test.go`:
- Around line 1172-1183: The test
TestReconcile_NilJobAgentSelector_CreatesFailureJob is now a duplicate of
TestReconcile_NoJobAgentSelector_CreatesFailureJob because JobAgentSelector is a
string (no nil case); remove TestReconcile_NilJobAgentSelector_CreatesFailureJob
or rename and change it to cover a distinct scenario (e.g., an invalid non-empty
selector value or whitespace-only selector) by updating the test body that
manipulates getter.deployment.JobAgentSelector and the corresponding assertions
in Reconcile to reflect the new behavior being tested.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 59217e09-c544-41f0-a037-f647d47e20f5

📥 Commits

Reviewing files that changed from the base of the PR and between c7920d5 and e016bbd.

📒 Files selected for processing (16)
  • apps/api/openapi/openapi.json
  • apps/api/openapi/schemas/deployments.jsonnet
  • apps/api/src/types/openapi.ts
  • apps/web/app/api/openapi.ts
  • apps/workspace-engine/oapi/openapi.json
  • apps/workspace-engine/oapi/spec/schemas/deployments.jsonnet
  • apps/workspace-engine/pkg/db/convert.go
  • apps/workspace-engine/pkg/oapi/oapi.gen.go
  • apps/workspace-engine/svc/controllers/deploymentplan/controller.go
  • apps/workspace-engine/svc/controllers/deploymentplan/controller_test.go
  • apps/workspace-engine/svc/controllers/jobdispatch/reconcile.go
  • apps/workspace-engine/svc/controllers/jobdispatch/reconcile_test.go
  • apps/workspace-engine/svc/controllers/jobeligibility/reconcile.go
  • apps/workspace-engine/svc/controllers/jobeligibility/reconcile_test.go
  • apps/workspace-engine/test/controllers/harness/pipeline.go
  • packages/workspace-engine-sdk/src/schema.ts

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Deployment OpenAPI schemas and generated clients/server types so jobAgentSelector is treated as a required field (string) rather than an optional/pointer field, and adjusts workspace-engine controllers/tests accordingly.

Changes:

  • Make jobAgentSelector required in Deployment schemas (workspace-engine + API) and propagate through generated OpenAPI artifacts/SDKs.
  • Update workspace-engine Go code to use deployment.JobAgentSelector as a string (remove nil-pointer handling) across controllers and tests.
  • Regenerate web/API OpenAPI TypeScript types reflecting the schema change (and other spec-driven additions).

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/workspace-engine-sdk/src/schema.ts Generated SDK types: jobAgentSelector now required on Deployment.
apps/workspace-engine/test/controllers/harness/pipeline.go Update test harness Deployment construction to pass selector as string.
apps/workspace-engine/svc/controllers/jobeligibility/reconcile.go Remove nil handling; treat selector as required string and update tracing attrs.
apps/workspace-engine/svc/controllers/jobeligibility/reconcile_test.go Update tests for non-pointer selector.
apps/workspace-engine/svc/controllers/jobdispatch/reconcile.go Remove nil handling; selector is a string.
apps/workspace-engine/svc/controllers/jobdispatch/reconcile_test.go Update test Deployment construction to pass selector as string.
apps/workspace-engine/svc/controllers/deploymentplan/controller.go Remove nil handling; selector is a string.
apps/workspace-engine/svc/controllers/deploymentplan/controller_test.go Update tests for non-pointer selector.
apps/workspace-engine/pkg/oapi/oapi.gen.go Generated Go types: Deployment.JobAgentSelector becomes string (required JSON field).
apps/workspace-engine/pkg/db/convert.go Always populate JobAgentSelector on OAPI Deployment conversion.
apps/workspace-engine/oapi/spec/schemas/deployments.jsonnet Workspace-engine schema marks jobAgentSelector as required.
apps/workspace-engine/oapi/openapi.json Generated OpenAPI JSON reflects required jobAgentSelector.
apps/web/app/api/openapi.ts Regenerated openapi-typescript output; jobAgentSelector required and other spec updates included.
apps/api/src/types/openapi.ts Generated API types: jobAgentSelector required on Deployment.
apps/api/openapi/schemas/deployments.jsonnet API schema marks jobAgentSelector as required.
apps/api/openapi/openapi.json Generated OpenAPI JSON reflects required jobAgentSelector.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Deployment: {
type: 'object',
required: ['id', 'name', 'slug', 'jobAgentConfig'],
required: ['id', 'name', 'slug', 'jobAgentSelector', 'jobAgentConfig'],
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

Making jobAgentSelector required in the Deployment schema appears inconsistent with current API behavior: apps/api/src/routes/v1/workspaces/deployments.ts formats jobAgentSelector as undefined when the stored value is null or the default string "false", which causes the property to be omitted from JSON responses. Either update the API formatting to always return a string value (e.g. include "false"/""), or keep jobAgentSelector optional in the Deployment response schema to match what the server actually returns.

Suggested change
required: ['id', 'name', 'slug', 'jobAgentSelector', 'jobAgentConfig'],
required: ['id', 'name', 'slug', 'jobAgentConfig'],

Copilot uses AI. Check for mistakes.
Comment on lines 1172 to +1176
func TestReconcile_NilJobAgentSelector_CreatesFailureJob(t *testing.T) {
rt := testRT()
release := testRelease(rt)
getter, setter := setupHappyPath(rt, release)
getter.deployment.JobAgentSelector = nil
getter.deployment.JobAgentSelector = ""
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

TestReconcile_NilJobAgentSelector_CreatesFailureJob is now identical to TestReconcile_NoJobAgentSelector_CreatesFailureJob because JobAgentSelector is no longer a pointer and both tests set it to the empty string. Consider removing one of these tests or repurposing it to cover a distinct scenario (e.g. selector explicitly set to "false" or invalid CEL).

Copilot uses AI. Check for mistakes.
Comment on lines 301 to 304
func TestProcess_EmptySelector_CompletesPlan(t *testing.T) {
dep := testDeployment(false)
emptySel := ""
dep.JobAgentSelector = &emptySel
dep.JobAgentSelector = ""

Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

testDeployment(false) already yields an empty JobAgentSelector (zero-value string), so explicitly setting dep.JobAgentSelector = "" here is redundant. This also effectively duplicates the "no selector" behavior already covered by TestProcess_NoAgents_CompletesPlan, and can mask coverage for the distinct case of a non-empty selector with zero matching agents.

Copilot uses AI. Check for mistakes.
@adityachoudhari26 adityachoudhari26 merged commit 4b01b97 into main Apr 8, 2026
18 checks passed
@adityachoudhari26 adityachoudhari26 deleted the make-selector-required branch April 8, 2026 21:43
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.

chore: update oapi to require a selector for deployments once all tf workspaces have been updated

2 participants