Skip to content

refactor(secretsmanager): extract version idempotency check#338

Merged
vieiralucas merged 1 commit intomainfrom
worktree-cleanup+secretsmanager-splits
Apr 13, 2026
Merged

refactor(secretsmanager): extract version idempotency check#338
vieiralucas merged 1 commit intomainfrom
worktree-cleanup+secretsmanager-splits

Conversation

@vieiralucas
Copy link
Copy Markdown
Member

@vieiralucas vieiralucas commented Apr 13, 2026

Summary

`create_secret`, `put_secret_value`, and `update_secret` each had the same inline `ClientRequestToken` idempotency check: look up an existing version with the same id and either return it as a no-op (if the payload matches) or fail with `ResourceExistsException` (if the payload differs).

Move that into `check_secret_version_idempotency`, which returns a three-variant enum (`NotFound` / `Match` / `Conflict`). Each caller still owns its success-response shape since they emit slightly different JSON (`create_secret` conditionally omits `VersionId`, `put_secret_value` includes `VersionStages`, `update_secret` returns just `ARN`/`Name`/`VersionId`), but the lookup+compare logic is now a single pure function instead of three inline copies.

No behavior change. Same error wording.

Test plan

  • `cargo fmt`
  • `cargo clippy --workspace --all-targets -- -D warnings`
  • `cargo test -p fakecloud-secretsmanager` (39 passed)

Summary by cubic

Extracted a shared ClientRequestToken version idempotency check in fakecloud-secretsmanager to remove duplicated logic across write operations. No behavior change; same success payloads and error wording.

  • Refactors
    • Added check_secret_version_idempotency (NotFound/Match/Conflict) to compare payloads by version id.
    • Updated create_secret, put_secret_value, and update_secret to call it while keeping their specific response shapes.

Written for commit b65a021. Summary will update on new commits.

create_secret, put_secret_value, and update_secret each had the same
inline ClientRequestToken idempotency check: look up an existing
version with the same id and either return it as a no-op (if the
payload matches) or fail with ResourceExistsException (if the payload
differs).

Move that into check_secret_version_idempotency, which returns a
three-variant enum (NotFound / Match / Conflict). Each caller still
owns its success-response shape since they emit slightly different
JSON (create_secret conditionally omits VersionId, put_secret_value
includes VersionStages, update_secret returns just ARN/Name/
VersionId), but the lookup+compare logic is now a single pure
function instead of three inline copies.

No behavior change. Same error wording.
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@vieiralucas vieiralucas merged commit c5af0ef into main Apr 13, 2026
22 checks passed
@vieiralucas vieiralucas deleted the worktree-cleanup+secretsmanager-splits branch April 13, 2026 02:39
vieiralucas added a commit that referenced this pull request Apr 13, 2026
…Input

The two longest functions in the SSM sub-modules were create_patch_baseline
(~150 lines) and create_association_inner (~162 lines). Both were dominated
by body parsing, field validation, and field extraction — with the actual
state mutation only in the last 30-40 lines.

This extracts dedicated *Input structs with from_body() constructors,
leaving each function focused on idempotency, ID generation, and struct
assembly. Same pattern as PRs #324/#328/#338/#355/#356.
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