Repository navigation
Description
Bug Description
devops k8s deploy-stack --stack infra ends with the exit code 1 when the kubeconfig context is a valid kubeconfig name that is no RFC 1123 name, such as an EKS ARN.
deploy-stack accepts the name (validate_k8s_context_name). After the Helm releases, sync_k8s_credentials calls fetch_secret_data, and fetch_secret_data checks the same name with validate_k8s_name(context, "context"), which accepts only RFC 1123 names. The command prints Invalid context: '<name>'. Must be a valid RFC 1123 name. and exits with 1 after it has deployed the stack.
A test hid this: test_deploy_and_teardown_stack_use_effective_context in tests/commands/k8s/test_k8s_context.py patched sync_k8s_credentials to return {}. The test now deploys the logging stack, which has no credentials to sync.
Steps to Reproduce
- Set
k8s.contexttoarn:aws:eks:us-east-1:123456789012:cluster/prod. - Run
devops k8s deploy-stack --stack infra --no-push-secretsagainst a cluster of that context. - See the error after the Helm releases and the exit code 1.
Expected Behavior
fetch_secret_data accepts every context name that switch-context and deploy-stack accept, and uses validate_k8s_context_name.
Existing Tool Considered
No new tool is needed. The fix calls validate_k8s_context_name, which exists in devops_cli.core.validation.
Related: #4086 (found while it removed the patch of sync_k8s_credentials).
Proposed design
Problem statement
The k8s credential sync refuses a kubeconfig context that is not an RFC 1123 name, such as an EKS ARN. deploy-stack accepts the name and deploys the stack. Then the sync exits with code 1. The sync must use the same context validator as switch-context and deploy-stack.
Acceptance criteria
Requirement: Context validator of the credential sync
fetch_secret_data SHALL validate the context name with validate_k8s_context_name.
Scenario: An EKS ARN context
- WHEN
fetch_secret_dataruns with the contextarn:aws:eks:us-east-1:123456789012:cluster/prod. - THEN It raises no validation error, and it reads the secret with
kubectl --contextset to that ARN.
Requirement: Deploy of the infra stack with an ARN context
devops k8s deploy-stack --stack infra SHALL finish with exit code 0 when the context is an EKS ARN.
Scenario: The infra stack deploys against an ARN context
- WHEN The command runs with an ARN context and
--no-push-secrets. - THEN The exit code is 0, and the output holds no
Must be a valid RFC 1123 namemessage.
Requirement: Rejection of an unsafe context name
fetch_secret_data MUST reject a context name that holds shell injection, a space or an empty string.
Scenario: A context name with a shell metacharacter
- WHEN
fetch_secret_dataruns with the contextbad; rm -rf /. - THEN It raises a validation error, and it starts no
kubectlprocess.
Requirement: Regression test on the infra stack
test_deploy_and_teardown_stack_use_effective_context SHALL cover the infra stack with an ARN context.
Scenario: The context test deploys the infra stack
- WHEN The test runs with the effective context set to an EKS ARN.
- THEN The deploy and the teardown both exit 0, and the test no longer uses the
loggingstack as a stand-in.
Existing Tool Considered
No alternatives check has run. No new tool or library is needed. validate_k8s_context_name in devops_cli.core.validation covers the need: it accepts every kubeconfig name that switch-context and deploy-stack accept, and it rejects shell injection. It lacks nothing for this fix.
Key questions
- Which validator should
fetch_secret_datause for the context name?: Usevalidate_k8s_context_name, the validator thatswitch-contextanddeploy-stackuse. (best practice) [sources: src/devops_cli/core/validation.py, src/devops_cli/k8s/credentials.py:160, src/devops_cli/commands/k8s/cluster_runtime.py, src/devops_cli/commands/argo.py:516, tests/core/test_validation.py]- Chosen:
validate_k8s_context_name. It accepts ARN, email and GKE names, and it rejects shell injection. The commands of the issue already use it. - Rejected:
validate_k8s_name. It accepts only RFC 1123 names, so it causes the defect. - Rejected: A new context validator. It duplicates an existing, tested function.
- Chosen:
- Does
sync_k8s_credentialsvalidate the context itself?: No. Its callers pass the context tofetch_secret_data, andfetch_secret_dataholds the check. [sources: src/devops_cli/k8s/credentials.py:160, src/devops_cli/k8s/credentials.py:208, src/devops_cli/k8s/credentials.py:237, src/devops_cli/commands/k8s/stack_lifecycle.py] - Should the end-to-end test deploy the
infrastack again?: Yes. Restore theinfrastack with the ARN context, so the test covers the defect end to end. (best practice) [sources: tests/commands/k8s/test_k8s_context.py:373, openspec/changes/archive/2026-11-08-4086-k8s-command-tests-on-edge-fakes/proposal.md:52]- Chosen: Restore the
infrastack. The test then covers the credential sync with an ARN context, which is the defect. - Rejected: Keep the
loggingstack. Theloggingstack syncs no credential, so the test leaves the regression uncovered.
- Chosen: Restore the
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Alternatives check of 2026-11-10: none.
Tool: none found.
Activity
dan-petty commentedon Nov 7, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
fixprefix of the title gives the type.(k8s)scope of the title gives the scope.The bug breaks a deploy workflow for non-RFC 1123 context names but only for a subset of users.It restores a broken deploy-stack exit path for users with EKS ARN context names.The fix swaps one validation call and updates one test.Both items work on credential sync in deploy-stack, but #741 adds the sync feature and the candidate fixes a validation bug in that path.devops-cli-service commentedon Nov 8, 2026
Status set to Ready at fe1d00b (see proposed design in issue body).
devops-cli-service commentedon Nov 10, 2026
Alternatives check: none
Reason: The issue is an internal bug in
devops_cli.k8s.credentials.fetch_secret_data, which validates a kubeconfig context with the RFC 1123-onlyvalidate_k8s_nameinstead of the existingvalidate_k8s_context_name. The searches turned up only generic input-validation pages, no library that validates kubeconfig context names (EKS ARNs, GKE, email names) or that would replace the repository's own validator, so no external tool covers the need.Tool: none found
Lacks:
Searches run:
Sources:
Checked on 2026-11-10. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 12, 2026
Released in v0.116.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.116.0
devops-cli-service commentedon Nov 12, 2026
Live since 2026-11-12 05:27 UTC