Skip to content

fix(mcp): fill env services from the plan when a client drops an empty array (SHIP-670) - #95

Merged
akshaykalia merged 3 commits into
mainfrom
danielle/fill-env-services-from-plan
Nov 12, 2026
Merged

akshaykalia merged 3 commits into
mainfrom
danielle/fill-env-services-from-plan

Conversation

@daniellle

@daniellle daniellle commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

SHIP-670. Kiro launch blocker, needed for tomorrow's demo.

In Kiro, create_application on the hosted server fails for every env var the plan lists with services: [], which is every variable a Compose file interpolates as ${NAME}: "env[0].services is required". The agent sends [], but Kiro drops empty arrays from tool arguments, so the field arrives missing. Our side accepts []: the hosted server passes arguments through unchanged, and json.Unmarshal gives a non-nil empty slice.

Fix

fillEnvServices runs in executeCreate before checkEnvItems. When any env item has no services, it reads the plan and gives each such item the services the plan lists for its name and kind. Interpolated variables get [] back.

It changes nothing, so checkEnvItems still refuses the item, when:

  • the plan can't be read (request fails, or the body isn't JSON), or answers needs_action (the refusal then points the agent at plan_application and its next_step)
  • the plan's head_sha differs from the confirmed one (the branch moved)
  • the plan doesn't list the variable with that name and kind
  • compose_filename names a different file than the plan's compose_file. Passing the plan's own file still gets the fill, since the schema asks agents to pass compose_filename when the plan's file isn't the default.

When an item is refused this way, the refusal says why, for example "the branch has moved past head_sha: run plan_application again and confirm the new plan". A client that drops [] can't follow "pass []", so it gets the step it can actually take. The reason is also logged, with names only, never values.

The "no value reaches every service by accident" guarantee holds: services come from the plan of the commit the user confirmed, never from a guess. It costs one extra plan request, and only when an item is missing services. Items that arrive with services are untouched.

Tests

  • TestCreateApplicationFillsMissingEnvServicesFromPlan: an interpolated variable gets [], a scoped one gets [api], and a build arg gets [web], from the plan, both without compose_filename and with the plan's own compose file. Every filled variable must be present. It fails on main with Kiro's exact error.
  • TestCreateApplicationRefusesEnvServicesThePlanCantGive: 8 refusal cases (the ones above, a needs_action answered with HTTP 409, a plan request that fails with HTTP 500, and a plan body that isn't JSON). Each still errors with its reason, and none sends a create.
  • TestCreateApplicationKeepsGivenEnvServices: items that arrive with services, an explicit [] included, keep them, and the plan is never requested.
  • The existing "create rejects an env item without services" case now gets a plan that doesn't list the variable, and checks the reason and that only the plan was requested.
  • go test ./... and go vet ./... pass. golangci-lint shows only the 7 issues main already has, none in files this PR touches.

docs/mcp.md: one sentence on the create_application row.

After merge

Release and deploy the hosted server, then I'll rerun the T6 create in Kiro with GREETING set.

🤖 Generated with Claude Code

…y array (SHIP-670)

Kiro drops empty arrays from tool arguments, so an interpolated variable
the plan lists with services [] reached create_application with no
services and was refused. When an env item has no services, take them
from the plan at the confirmed head_sha; refuse as before when the plan
can't give them (unreadable or needs_action, branch moved, variable not
listed, or a compose_filename the plan can't see).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hy a fill was skipped (SHIP-670)

The fill gave up whenever compose_filename was set, but the create schema
asks agents to pass it when the plan's compose_file is not the default, so
an agent echoing the plan's own file still hit the refusal. It now reads the
plan first and gives up only when compose_filename names a different file.

When an item is still left without services, the refusal says why (the
branch moved, the plan could not be read, the plan lists no such variable)
and the reason is logged, names only. A client that drops [] can't follow
"pass []", so it needs the next step instead.

Tests now require every filled variable, check the build arg's services,
and cover a plan request that fails and a plan body that isn't JSON.
…670)

When core answers the plan with an action-required error, such as installing
the GitHub app, the refusal said the plan could not be read. plan_application
passes that answer through, so the refusal now points the agent at it too.

Tests: the old "env item without services" case answered the new plan request
from a server with no status, so it passed through a handler panic. It now
gets a plan that doesn't list the variable and checks the reason and that no
create is sent. A new test checks that items arriving with services, an
explicit [] included, skip the plan and keep their own services.
@akshaykalia
akshaykalia merged commit f97d5ae into main Nov 12, 2026
6 checks passed
@akshaykalia
akshaykalia deleted the danielle/fill-env-services-from-plan branch November 12, 2026 16:20
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.

2 participants