Skip to content

Fix two behaviors PR 2's tests pinned as quirks#28

Merged
AbsolutOD merged 2 commits into
mainfrom
fix/hyphens-and-bypath-fallback
May 7, 2026
Merged

Fix two behaviors PR 2's tests pinned as quirks#28
AbsolutOD merged 2 commits into
mainfrom
fix/hyphens-and-bypath-fallback

Conversation

@AbsolutOD

Copy link
Copy Markdown
Owner

Summary

Stacked on #27. Fixes the two behaviors PR 2 flagged as "notable items pinned by the new tests":

  1. formatParamName now converts hyphens to underscores. esp's purpose is to expose SSM params as environment variables; env var names cannot contain hyphens. The function already uppercased un-prefixed names — extending the same step to replace hyphens makes the output a valid identifier. esp put -n my-app-key -v ... now produces ACME_MY_APP_KEY instead of the half-normalized ACME_MY-APP-KEY. The HasPrefix branch is unchanged: callers passing a fully-formed name keep it verbatim.
  2. checkSSMByPathError now has the smithy.APIError fallback its siblings already have. Previously this was the only mapper missing the trailing generic-API catch, so any GetParametersByPath failure outside the explicit list (throttling, auth, region issues) mapped to nil and would be silently swallowed by callers using this mapper. The dispatcher does not currently route GetMany here, so today this is defensive — but the function is shaped to be reused, and any future caller would have inherited the swallow bug.

Both behaviors were the design doc's stated intent; the code shipped without them. Tests added in #27 are updated in lockstep — the assertion that previously read "hyphens preserved" now reads "hyphens become underscores", and the assertion that read "no fallback in this function" now reads "falls through and is returned".

Stacking

PR base is feature/tests-pure-logic (#27). After #27 merges, GitHub will automatically retarget the base of this PR to main.

Test Plan

  • go build ./... clean
  • go vet ./... clean
  • go test ./... — all packages pass; the two updated table cases now assert the new behavior

Commits

  1. fix(cmd/put): normalize hyphens to underscores in formatParamName
  2. fix(internal/ssm): add smithy.APIError fallback to checkSSMByPathError

Base automatically changed from feature/tests-pure-logic to main May 7, 2026 01:24
AbsolutOD added 2 commits May 6, 2026 21:30
esp's purpose is to expose SSM params as environment variables,
and env var names cannot contain hyphens. formatParamName already
uppercased un-prefixed names; extend the same step to replace
hyphens with underscores so callers like

    esp put -n my-app-key -v ...

produce a valid env var name (ACME_MY_APP_KEY) rather than the
half-normalized ACME_MY-APP-KEY that survived before.

The HasPrefix branch is unchanged: callers who pass a fully-formed
name keep it verbatim, hyphens and all. TestEspName updated to
pin the new rule and adds a multiple-hyphens case plus an
already-prefixed-with-hyphens case that documents the asymmetry.

Surfaced by writing the PR 2 tests; design doc described this
conversion but the code wasn't doing it.
checkSSMByPathError was the only mapper without a trailing
smithy.APIError catch — its sibling functions (checkBaseSSMErrors,
checkSSMGetParameterError, checkSSMPutParameterError,
checkDeleteParameterError) all fall through to a generic API
error before returning nil. The asymmetry meant any
GetParametersByPath failure not in the explicit list (throttling,
auth, region issues) would map to nil and be silently swallowed
by callers using this mapper.

Today the dispatcher (checkSSMError) does not actually route
GetMany to this function, so the fix is mostly defensive. Worth
doing now: the function is exported-shaped and any future caller
would inherit the swallow bug otherwise.

TestCheckSSMByPathError updated; the case that previously asserted
"returns nil (no fallback in this function)" now asserts
fallthrough-and-return, matching the siblings.

Surfaced by writing the PR 2 tests.
@AbsolutOD AbsolutOD force-pushed the fix/hyphens-and-bypath-fallback branch from e37b0ba to 08a83a2 Compare May 7, 2026 01:30
@AbsolutOD AbsolutOD merged commit 95bc540 into main May 7, 2026
@AbsolutOD AbsolutOD deleted the fix/hyphens-and-bypath-fallback branch May 7, 2026 01:47
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.

1 participant