stacklok / stacklok/toolhive

MCPServer spec.secrets list-map-keys=[name] makes two keys from one Secret unrepresentable

Open
#6,686 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs-triage
Dominant language
Go
Stars
2.2k
Forks
300
Avg merge
1d 15h
Merged PRs (30d)
184

Description

The 0.49.0 CRDs declare spec.secrets as x-kubernetes-list-type: map with x-kubernetes-list-map-keys: [name], but every entry is a per-key reference {name, key, targetEnvName} (name and key both required).

The operator's env builder (cmd/thv-operator/pkg/controllerutil/podtemplatespec_builder.go, WithSecrets) maps each entry to one secretKeyRef env var, so referencing several keys of the SAME Secret is the intended use — but with the merge keys on [name] alone that shape is unrepresentable: any CR listing two entries with the same secret name fails server-side apply/dry-run with duplicate entries for key [name="..."]. Mine (one Secret, five keys) fails exactly that way against the 0.49.0 CRDs; the same manifest was fine against 0.0.106, which had no list-type markers.

A CR-side workaround (splitting one Secret into N single-key Secrets) is ugly, so I patched the CRD's list-map-keys to [name, key] via a post-renderer — everything else about the schema works, and the operator code already treats entries as per-key.

Affects both served versions (v1alpha1 and v1beta1) and is still on main.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with cmd/thv-operator/pkg/controllerutil/podtemplatespec_builder.go and the WithSecrets entry point, then inspect the CRD schemas for v1alpha1 and v1beta1. Reproduce the server-side apply or dry-run failure using two entries with the same Secret name and different keys. Done means both keys are representable and the affected CRDs accept the manifest.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, kubernetes
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
75/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.