fix: split HashiCorp Vault namespace/path_prefix and validate store status#14
Merged
Merged
Conversation
sebasnallar
approved these changes
Jul 21, 2026
jcastiarena
approved these changes
Jul 21, 2026
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.
Problem
On a HashiCorp Vault Enterprise namespace,
parameter:storereturned success butparameter:retrievethen 404'd for the sameexternal_id.Two chained defects:
store.storeonly checkedcurl's exit code.curl -sexits 0 even on HTTP 4xx/5xx, so a failed KV write was reported as success (the returnedexternal_idcame back with no#versionsuffix — a tell that.data.versionwas absent and the POST never produced a KV v2 write body).setup.namespacefield + "strip trailing/data" heuristic meantadmin/ns/data→ namespaceadmin/ns, KV pathdata/…. But a real KV v2 write needs<namespace>/<mount>/data/<subpath>— the mount name (e.g.secret) had no place, so the write landed on a non-existent path. No single value made both login and read/write work.Fix
storenow validates the HTTP status (-w "%{http_code}") and fails loudly with the Vault response body on non-2xx.setup.namespace(envVAULT_NAMESPACE) — Vault Enterprise namespace, applied as a URL prefix on login and every store/retrieve/delete request. Empty = root namespace (backward compatible with Vault OSS).setup.path_prefix(envVAULT_PATH_PREFIX, defaultsecret/data/nullplatform) — the KV v2<mount>/data/<subpath>prefix, embedded in theexternal_id./dataheuristic.store/retrieve/deletecompose the namespace prefix consistently; the Vault namespace is no longer embedded in theexternal_id(changing it is a migration, documented).setupvalidatesnamespace/path_prefixagainst[A-Za-z0-9._/-]and rejects..before interpolating into URLs (defense-in-depth).variables.tf,locals.tf,terraform.tfvars.example), README, architecture doc, and CHANGELOG.Migration note
setup.namespaceno longer holds the KV path. Configure the two fields separately, e.g. for an HCP namespaceadmin/eks-null-alfa-136with the default KV mount:namespace = admin/eks-null-alfa-136path_prefix = secret/dataTest plan
batssuite: 190/190 passing, including new regression tests for the silent-write bug (non-2xx → failure), the namespace URL-prefix on store/retrieve/delete, and namespace/path_prefix validation.tofu validateon the install spec: OK.