Skip to content

refactor(sqs): extract create_queue validation and redrive-policy helpers#328

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

refactor(sqs): extract create_queue validation and redrive-policy helpers#328
vieiralucas merged 1 commit intomainfrom
worktree-cleanup+sqs-splits

Conversation

@vieiralucas
Copy link
Copy Markdown
Member

@vieiralucas vieiralucas commented Apr 13, 2026

Summary

`create_queue` had three inline validation blocks that each deserved to be its own function:

  • DelaySeconds (0–900) and MaximumMessageSize (1024–1 MiB) validation → `validate_create_queue_attributes`.
  • `RedrivePolicy` JSON parsing (the 12-line closure that pulled `deadLetterTargetArn` and a `maxReceiveCount` coerced from either a number or a string) → `parse_redrive_policy`.
  • `RedrivePolicy` target validation (DLQ must exist, and a FIFO source cannot use a standard DLQ) → `validate_redrive_policy_target`.

`create_queue` itself gets 80 lines shorter. No behavior change — same `AwsServiceError` codes, same messages (including the `AWS.SimpleQueueService.NonExistentQueue` `x-amzn-query-error` header on the DLQ-not-found path), same order.

Test plan

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

Summary by cubic

Refactored fakecloud-sqs to extract create_queue validation and redrive-policy logic into small helpers, making the function ~80 lines shorter with no behavior changes.

  • Refactors
    • Moved DelaySeconds and MaximumMessageSize checks to validate_create_queue_attributes.
    • Added parse_redrive_policy to parse JSON and coerce maxReceiveCount from string or number.
    • Added validate_redrive_policy_target to verify DLQ exists and enforce FIFO-to-FIFO, preserving existing error codes/messages and the x-amzn-query-error header.

Written for commit 1fb1111. Summary will update on new commits.

…pers

create_queue had three inline validation blocks that each deserved to
be its own function:

- DelaySeconds (0–900) and MaximumMessageSize (1024–1 MiB) validation:
  now validate_create_queue_attributes.
- RedrivePolicy JSON parsing (the 12-line closure that pulled
  deadLetterTargetArn and a maxReceiveCount coerced from either a
  number or a string): now parse_redrive_policy.
- RedrivePolicy target validation (DLQ must exist, and a FIFO source
  cannot use a standard DLQ): now validate_redrive_policy_target.

create_queue itself gets 80 lines shorter. No behavior change — same
AwsServiceError codes, same messages (including the
AWS.SimpleQueueService.NonExistentQueue x-amzn-query-error header on
the DLQ-not-found path), same order.
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 b5e8cff into main Apr 13, 2026
22 checks passed
@vieiralucas vieiralucas deleted the worktree-cleanup+sqs-splits branch April 13, 2026 01:32
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