Skip to content

api: ?env= query filter on list endpoints (slice 1)#27

Merged
mastermanas805 merged 1 commit into
masterfrom
slice-1-env-filter-2026-05-12
May 12, 2026
Merged

api: ?env= query filter on list endpoints (slice 1)#27
mastermanas805 merged 1 commit into
masterfrom
slice-1-env-filter-2026-05-12

Conversation

@mastermanas805
Copy link
Copy Markdown
Member

Summary

  • GET /api/v1/resources?env=staging and GET /api/v1/deployments?env=staging filter server-side by the env column
  • Omitting ?env= returns all envs (backward compatible)
  • Bogus envs (uppercase, spaces, unicode) fail NormalizeEnv and return 200 + empty — keeps the UI stable on stale client state

Slice 1 of the env-aware deployments plan in ENV-AWARE-DEPLOYMENTS-DESIGN.md. Closes the most-visible cosmetic-env gap: switching the dashboard sidebar env switcher to staging now actually filters the lists. Remaining slices (resource family schema, provision-twin, family deploy bindings, vault auto-copy on promote, per-env access policy) are queued.

Test plan

  • Unit tests: 6 cases in `internal/handlers/list_env_filter_test.go` — no filter returns all envs, `?env=staging` filters correctly, bogus env returns 200 + empty for both endpoints
  • Full handler test suite (`go test ./internal/handlers/`) passes
  • Live verify after deploy: switch the production dashboard env switcher to staging, observe lists filter
  • Live curl: `curl -H "Authorization: Bearer $JWT" https://api.instanode.dev/api/v1/resources?env=staging\` returns 200 + JSON

🤖 Generated with Claude Code

…yments)

GET /api/v1/resources and GET /api/v1/deployments accept an optional ?env=
query parameter, server-side filtering by the resources.env / deployments.env
column. Omitting it returns all envs (backward compatible).

Bogus envs (uppercase, spaces, unicode) fail NormalizeEnv and return 200 +
empty — keeps the dashboard stable on stale client state instead of 400-ing.

Closes the most-visible cosmetic-env gap from ENV-AWARE-DEPLOYMENTS-DESIGN.md
§4 slice 1: switching the dashboard env switcher to "staging" now genuinely
filters the resources + deployments lists. Slice 1 is the smallest user-visible
win in the 6-slice plan; the remaining slices (family schema, provision-twin,
family deploy bindings, vault auto-copy on promote, per-env access policy) are
queued behind it.

Tests: internal/handlers/list_env_filter_test.go (6 cases) — no filter
returns all envs, ?env=staging filters correctly, bogus env returns
200+empty for both endpoints.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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