env: default to 'development' (not 'production') + API explicitly echoes resolved env on every response#63
Merged
Conversation
…on every response
Migration 026 flips the column DEFAULT on resources.env, deployments.env,
and stacks.env from 'production' to 'development' so accidental no-env
provisions land in the lowest-stakes bucket instead of silently merging
with real prod state. Existing rows are NOT touched — only the DEFAULT.
API layer:
- models.NormalizeEnv now returns "development" for empty input
- new models.EnvDevelopment + models.EnvDefault constants
- models.CreateResource/Deployment/Stack default Env to EnvDefault
- middleware/env_policy default env name updated to match
- provisioning, deploy, and stack handlers already echo env (or
"environment" on /deploy/new where "env" means env_vars); POST
/stacks/new now echoes "env" too
- openapi.go default + descriptions updated
Tests:
- regression test TestAllProvisioningResponsesIncludeEnv across
/db, /cache, /nosql, /webhook, /storage — asserts response
includes top-level "env":"development" + DB row matches
- TestMigration026_DoesNotTouchExistingRows guards against an
accidental UPDATE-existing-rows regression
- existing TestNormalizeEnv_/TestDeploymentEnv_CreateDefaults
tests rewritten to assert 'development'
- TestStackList env assertion flipped to 'development'
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…velopment-fresh # Conflicts: # internal/models/deployment.go
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
resources.env,deployments.env, andstacks.envfrom'production'to'development'. Existing rows are NOT touched — only the DEFAULT changes. Accidental no-env provisions now land in the lowest-stakes bucket instead of silently merging with real prod state.models.NormalizeEnv,CreateResource/CreateDeployment/CreateStack, the env-policy middleware default, and theresolveEnvdoc all point at"development". New typed constantsmodels.EnvDevelopment+models.EnvDefaultso future call sites don't hardcode the string.env;POST /stacks/newwas the one gap and now emits"env"too./deploy/newcontinues to use"environment"because"env"already means env_vars on that endpoint (deliberate naming collision documented indeploymentToMap).Backward compat
env="production"are unchanged.ALTER COLUMN ... SET DEFAULT— noUPDATE, no row rewrites.TestMigration026_DoesNotTouchExistingRowsguards this.TestResourceEnv_MigrationIdempotent).Test plan
make test-unitgreen (all packages)TestAllProvisioningResponsesIncludeEnv— new regression across /db, /cache, /nosql, /webhook, /storageTestMigration026_DoesNotTouchExistingRows— guards iron ruleTestNormalizeEnv_DefaultsToDevelopment,TestResourceEnv_CreateDefaultsToDevelopment,TestDeploymentEnv_CreateDefaultsToDevelopmentTestAgentActionContract+TestAgentActionContract_RegistryCoveragegreenTestStackListupdated assertion (default stack env is nowdevelopment)🤖 Generated with Claude Code