Skip to content

fix(tls): enable-k8s refuses a context that is no RFC 1123 name #4883

Done

Description

@dan-petty

Bug Description

devops tls enable-k8s --context <name> refuses a valid kubeconfig context name that is not an RFC 1123 name, such as an EKS ARN. enable_k8s_cmd in src/devops_cli/commands/tls.py checks the context with validate_k8s_name(context, "context"), which accepts only RFC 1123 names. The other k8s commands (switch-context, deploy-stack, argo, volume, tunnel) check the context with validate_k8s_context_name, which accepts ARN, GKE and user-account names and refuses shell metacharacters.

#4091 fixes the same defect in the Secret read of the credential sync.

Steps to Reproduce

  1. Run devops tls enable-k8s --context arn:aws:eks:us-east-1:123456789012:cluster/prod --dry-run.
  2. See Invalid context: 'arn:aws:eks:us-east-1:123456789012:cluster/prod'. Must be a valid RFC 1123 name.

Expected Behavior

devops tls enable-k8s accepts every context name that deploy-stack accepts, and checks it with 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.

Source: #4091

Alternatives check of 2026-11-27: none.
Tool: none found.
Reason: Searches found no external package that validates kubeconfig context names in ARN, GKE or user-account form while refusing shell metacharacters; the Kubernetes Python client validates config files, not names, so the in-repo validator swap stands.

Lacks:

  • No public context-name validator accepting EKS ARN, GKE or user-account forms
  • No refusal of shell metacharacters in context names
  • No reusable check that other commands could share instead of the in-repo validator

Proposed design

Problem statement

The devops tls enable-k8s --context command refuses a valid kubeconfig context name. It checks the context with validate_k8s_name, which accepts only RFC 1123 names. An EKS ARN such as arn:aws:eks:us-east-1:123456789012:cluster/prod is such a name. The other k8s commands accept it with validate_k8s_context_name. The change swaps the validator in enable_k8s_cmd.

Acceptance criteria

Requirement: EKS ARN context accepted

devops tls enable-k8s SHALL accept each kubeconfig context name that deploy-stack accepts, including an EKS ARN.

Scenario: Dry run with an EKS ARN context

  • WHEN the user runs devops tls enable-k8s --context arn:aws:eks:us-east-1:123456789012:cluster/prod --dry-run
  • THEN the command exits with status 0 and prints no RFC 1123 context error.

Requirement: Context validator parity

enable_k8s_cmd SHALL check the context with validate_k8s_context_name.

Scenario: The command calls the context validator

  • WHEN a test patches validate_k8s_context_name in devops_cli.commands.tls and runs enable-k8s --context arn:aws:eks:us-east-1:123456789012:cluster/prod --dry-run
  • THEN the patch records one call with that context and validate_k8s_name receives no call with the label context.

Requirement: Shell metacharacters refused

devops tls enable-k8s MUST refuse a context name that contains a shell metacharacter.

Scenario: Context with a shell metacharacter

  • WHEN the user runs devops tls enable-k8s --context 'prod;whoami' --dry-run
  • THEN the command exits with a non-zero status and prints an invalid context error.

Requirement: Namespace names stay RFC 1123

devops tls enable-k8s SHALL keep the RFC 1123 check on each namespace name.

Scenario: Invalid namespace with a valid ARN context

  • WHEN the user runs devops tls enable-k8s --context arn:aws:eks:us-east-1:123456789012:cluster/prod --namespace Bad_NS --dry-run
  • THEN the command exits with a non-zero status and prints an invalid namespace error.

Requirement: ARN context reaches kubectl

devops tls enable-k8s SHALL pass the accepted context to each kubectl call.

Scenario: The secret apply gets the ARN context

  • WHEN a test patches run_subprocess and runs enable-k8s --context arn:aws:eks:us-east-1:123456789012:cluster/prod with existing certificates
  • THEN each recorded argv contains arn:aws:eks:us-east-1:123456789012:cluster/prod.

Existing Tool Considered

No external tool or library covers this need. The alternatives check of 2026-11-14 found no package that validates kubeconfig context names in the ARN, GKE and user-account forms. The fix reuses the in-repo validator validate_k8s_context_name (src/devops_cli/core/validation.py:560), which the other k8s commands already call. It adds no code that the project must keep: the change swaps one import and one call, about two lines.

Key questions

  • Which validator must enable_k8s_cmd use for the --context value?: Use validate_k8s_context_name from devops_cli.core.validation. It accepts ARN, GKE and user-account names, and it refuses shell metacharacters. (best practice) [sources: src/devops_cli/core/validation.py:560, src/devops_cli/commands/tls.py:420, src/devops_cli/commands/k8s/cluster_runtime.py, src/devops_cli/commands/argo.py, src/devops_cli/commands/k8s/volume.py, src/devops_cli/commands/k8s/tunnel.py, src/devops_cli/k8s/credentials.py, openspec/changes/archive/2026-11-12-4091-credential-sync-refuses-a-context-that/design.md:12]
    • Chosen: Reuse validate_k8s_context_name. It already accepts the kubeconfig name forms and refuses shell metacharacters. Every other k8s command uses it, and tests/core/test_validation.py tests it.
    • Rejected: Write a new context validator. A second validator duplicates the tested one, as the archived design of fix(k8s): credential sync refuses a context that is no RFC 1123 name #4091 states.
    • Rejected: Relax validate_k8s_name. The same function checks namespace names and other RFC 1123 names, so a relaxation weakens those checks.
  • Does the context check cover the dry-run path and the real run?: Yes. enable_k8s_cmd checks the context before the dry-run branch, so both paths use the same check. [sources: src/devops_cli/commands/tls.py]
  • Does the fix change the namespace check?: No. The loop keeps validate_k8s_name(ns, "namespace", namespace=True) for each namespace. [sources: src/devops_cli/commands/tls.py]
  • Does the command pass the context to the kubectl argv builders?: Yes. plan_enable_k8s, namespace_check_argv, namespace_create_argv, secret_render_argv and secret_apply_argv take the context and place it in the argv. [sources: src/devops_cli/crypto/tls_plans.py, src/devops_cli/commands/tls.py, openspec/changes/archive/2026-11-01-2258-repos-branches-ssh-and-tls-commands/design.md:9]
  • Where do the tests of enable_k8s_cmd live?: tests/commands/test_tls_cmd.py. The test patches run_subprocess, so it can record the kubectl argv offline. [sources: tests/commands/test_tls_cmd.py, openspec/changes/archive/2026-11-01-2258-repos-branches-ssh-and-tls-commands/design.md:9]
  • Does this item depend on fix(k8s): credential sync refuses a context that is no RFC 1123 name #4091?: No. fix(k8s): credential sync refuses a context that is no RFC 1123 name #4091 changed fetch_secret_data in src/devops_cli/k8s/credentials.py, and its change is archived. This fix changes src/devops_cli/commands/tls.py only. [sources: openspec/changes/archive/2026-11-12-4091-credential-sync-refuses-a-context-that/proposal.md, src/devops_cli/k8s/credentials.py, src/devops_cli/commands/tls.py]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    on Nov 12, 2026
  2. added
    type/bug
    status/new
    value/medium
    effort/low
    on Nov 12, 2026
  3. removed
    effort/low
    on Nov 12, 2026
  4. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/bug. The fix prefix of the title gives the type.
    • Scope: none. The title has the scope tls, and .github/labels.yml declares no scope/tls label. Add the label to the file to give the scope to this item.
    • Priority: P2-Medium. It blocks a valid workflow for users with EKS ARN context names, but other commands already work.
    • Value: Medium. Users with non-RFC 1123 context names cannot run tls enable-k8s until this is fixed.
    • Effort: Low. The fix replaces one function call with an existing validator already used by other commands.
  5. added
    effort/low
    on Nov 12, 2026
  6. added
    priority/p2-medium
    and removed
    effort/low
    on Nov 12, 2026
  7. devops-cli-service commented on Nov 12, 2026

    @devops-cli-service
    Contributor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Scope: none. The title has the scope tls, and .github/labels.yml declares no scope/tls label. Add the label to the file to give the scope to this item.
    • Priority: P2-Medium. The bug blocks a documented workflow for EKS users, but it affects one command only.
    • Value: Medium. Users with ARN or GKE context names cannot run enable-k8s until the fix lands.
    • Effort: Low. The fix replaces one validation call with an existing function.
    • Related: fix(cli): argo ignores the namespace, and workspace, devcontainer, port-forward, tls, drift-report and label state handling #961, which asks for a different change. Both items touch the tls command, but #961 fixes state handling and the candidate fixes context-name validation.
  8. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Alternatives check: none

    Reason: Searches for a Kubernetes context-name validation library returned only unrelated generic validation pages (MDN), no tool that validates kubeconfig context names such as EKS ARNs. The issue itself asks for no new dependency: it is an internal one-line fix that swaps validate_k8s_name for the existing validate_k8s_context_name in devops_cli.core.validation, which the other k8s commands already use.

    Tool: none found

    Lacks:

    • No external tool or library is needed; the fix reuses the in-repo validate_k8s_context_name validator
    • Searches found no package that validates kubeconfig context names including ARN, GKE and user-account forms

    Searches run:

    • python library validate kubectl context name ARN GKE, results: 5
    • Kubernetes kubeconfig context name validation library RFC 1123 EKS ARN, results: 5

    Checked on 2026-11-14. A person decides what this means for the item. The check changes no label and closes no issue.

  9. added
    status/ready
    and removed
    status/new
    on Nov 15, 2026
  10. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at ca62d6a (see proposed design in issue body).

  11. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 29, 2026
  12. removed
    status/in-review
    owner/agent
    on Nov 29, 2026
  13. devops-cli-service commented on Nov 29, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-29 16:17 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p2-mediumsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions