Skip to content

fix: recfilter, aws and httpclient nits from the #220, #221 and #234 reviews - #501

Merged
cristim merged 4 commits into
mainfrom
test/227-recfilter-aws-httpclient-nits
Oct 17, 2026
Merged

cristim merged 4 commits into
mainfrom
test/227-recfilter-aws-httpclient-nits

Conversation

@cristim

@cristim cristim commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Summary

Items 1-3 of #227 (nits from the #220, #221 and #234 reviews), one commit each plus a follow-up test commit:

  1. fix(recfilter): pkg/recfilter/sizing.go:376 printed the target with %v while its five siblings use %.1f%%; it now matches. Log text only; a NaN-input test pins the message.
  2. fix(aws): appendOrgAccounts (providers/aws/provider.go) fell back to the caller account alone, silently, when the first ListAccounts page returned AccessDenied or NotInUse. It now logs that fallback at Info (the level the issue asks for). Behavior is unchanged: the first-page fallback stays as documented, and errors on page 2 and later still propagate, so a partial list cannot slip through. Added subtests for two pages, four pages (the caller account skipped), and NotInUse on page 2; a follow-up commit captures the logger (existing logging.SetOutput seam, restored in t.Cleanup) and asserts the fallback line.
  3. test(httpclient): the issue's premise was partly off. 169.254.0.0/16 is blocked whole, so 169.254.169.253 and .255 are pinned as blocked. The /128 and /32 entries (fd00:ec2::23 and ::254, fd20:ce::254, 168.63.129.16, 100.100.100.200) get allowed-neighbor cases; each neighbor was checked against the block list and the embedded-IPv4 prefixes.

Refs #227. Items 4-5 touch providers/gcp/provider.go and provider_test.go, which open PR #493 edits; they follow after it merges.

Evidence

Mutation probes (implementer and reviewer, scratch copies or reverted in-place edits):

  • restoring %v fails the NaN test;
  • dropping the page == 0 guard fails the page-2 tests, an early break fails five tests, deleting the Info log fails both first-page subtests;
  • widening any of the five narrow block entries (to /64, /24 or /124) fails the new allowed-neighbor test.

go test -race -count=5 on the providers/aws root package passes (the only t.Parallel there is a top-level test, so the global logger swap in serial subtests cannot overlap it).

Verification

make build, make vet, (cd pkg && GOWORK=off go test -race -short ./recfilter/... ./httpclient/...), (cd providers/aws && GOWORK=off go test -race -short .), pinned golangci-lint v2.10.1 on pkg and providers/aws (0 issues), gofmt, and the commit/pre-push hooks pass.

Local review: two adversarial passes by a non-author reviewer. Pass 1 found the Info log unpinned (fixed in the fourth commit); pass 2 found nothing actionable.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Improvements
    • AWS account discovery now logs an informational message when it falls back to the caller account after a recognized Organizations error on the first page.
    • Recommendation warnings display target coverage percentages with one decimal place.
  • Tests
    • Added coverage for metadata-adjacent IP address filtering, recommendation warning formatting, and AWS account discovery fallback and pagination behavior.

@cristim cristim added impact/internal Team-internal only type/chore Maintenance / non-user-visible priority/p3 Polish / idea / may never ship severity/low Minor harm urgency/eventually No deadline effort/s Hours triaged Item has been triaged labels Oct 17, 2026
@cristim

cristim commented Oct 17, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: LeanerCloud/cloud-commitments-go/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 3b2a17c5-c8e6-4743-ac0d-eafc052e34fa
📥 Commits

Reviewing files that changed from the base of the PR and between 1c19492 and 9344fe7.

📒 Files selected for processing: 5
  • pkg/httpclient/httpclient_test.go
  • pkg/recfilter/sizing.go
  • pkg/recfilter/sizing_test.go
  • providers/aws/provider.go
  • providers/aws/provider_test.go

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

📝 Walkthrough

The pull request adds metadata-address tests, formats invalid target-coverage warnings to one decimal place, and adds AWS Organizations fallback logging and account-pagination coverage.

Changes: Metadata address tests

Layer / File(s) Summary
Address boundary coverage
pkg/httpclient/httpclient_test.go
Adds assertions that selected link-local addresses are blocked and neighboring addresses around metadata entries remain allowed.

Target coverage warning format

Layer / File(s) Summary
Warning format and validation
pkg/recfilter/sizing.go, pkg/recfilter/sizing_test.go
Formats the invalid-input warning target percentage to one decimal place. The test checks the formatted message and dropped recommendation for a NaN input.

AWS Organizations account handling

Layer / File(s) Summary
Fallback and pagination behavior
providers/aws/provider.go, providers/aws/provider_test.go
Logs when a first-page Organizations error triggers fallback to the caller account. Tests cover fallback logging, accounts across successful pages, caller-account deduplication, ordering, and a later-page error.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 9344f

This change only adjusts a warning's formatting, adds an informational log and adds tests, so runtime behavior is unchanged. No merge-blocking risk is evident.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title accurately identifies fixes in recfilter, AWS, and httpclient, which match the main changes in the pull request. The wording is concise and specific enough despite using “nits” as a broad re…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title accurately identifies fixes in recfilter, AWS, and httpclient, which match the main changes in the pull request. The wording is concise and specific enough despite using “nits” as a broad review term.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim

cristim commented Oct 17, 2026

Copy link
Copy Markdown
Member Author

Independent review: CLEAN at 22b7a8422fe38bb331576893efadda8a17cdfdea. Reviewer: claude-go-pr-merge-4 (merge driver, not the author). The PR body was treated as a claim.

The non-test diff is two lines:

  • pkg/recfilter/sizing.go:376: %v becomes %.1f%% for the target-coverage warning, matching its siblings. Log text only.
  • providers/aws/provider.go: one logging.Infof on the first-page AccessDenied or NotInUse fallback. The control flow is unchanged: page 0 still returns the caller account and later pages still propagate the error. The logged error text can include the caller ARN; that matches the existing Warnf on the mid-run path two lines below, and it goes to local logs only.

Mutation probes, run locally in a scratch copy and reverted:

  • Deleting the new Infof FAILS TestAWSProvider_GetAccounts_WithMock, in the not-in-an-Organization and access-denied subtests.
  • Restoring %v FAILS TestApplyTargetCoverage_InvalidInputLogFormatsTarget.

Pass-after on macOS at this SHA:

  • (cd pkg && GOWORK=off go test -race -short ./recfilter/... ./httpclient/...) passes.
  • (cd providers/aws && GOWORK=off go test -race -short .) passes.
  • make build and make vet pass.

Labels mirror #227. CodeRabbit is quota-limited. If that holds at merge: CR waived: quota, adversarial review + local verification + green CI.

@cristim
cristim force-pushed the test/227-recfilter-aws-httpclient-nits branch from 22b7a84 to b550846 Compare October 17, 2026 03:08
@cristim

cristim commented Oct 17, 2026

Copy link
Copy Markdown
Member Author

Updated onto main 5910502 (after #499 and #500) using server-side update-branch. New head b550846502a8b6db1ea3ae323eb326a34de1afb4. git range-diff shows all four commits identical (22b7a84 = b550846 for the tip), so the CLEAN verdict carries over. CI had passed on 22b7a84 and is re-running. CR waived: quota, adversarial review + local verification + green CI.

cristim and others added 4 commits October 17, 2026 05:19
Refs #227

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Log at info when ListAccounts is denied or the account is not in an organization on the first page, so the single-account fallback is visible. Add page-two success, three-plus page and page-two NotInUse tests.

Refs #227

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…es stay allowed

Refs #227

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #227

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cristim
cristim force-pushed the test/227-recfilter-aws-httpclient-nits branch from b550846 to 9344fe7 Compare October 17, 2026 03:19
@cristim

cristim commented Oct 17, 2026

Copy link
Copy Markdown
Member Author

Updated again onto main 1c19492 (after #502). New head 9344fe78eae237f3c04b92dcf23632f672862af1, with every commit identical per git range-diff. The CLEAN verdict carries over. CI is re-running. CR waived: quota, adversarial review + local verification + green CI.

@cristim
cristim merged commit 4e7ef1e into main Oct 17, 2026
15 checks passed
@cristim
cristim deleted the test/227-recfilter-aws-httpclient-nits branch October 17, 2026 03:28
@cristim

cristim commented Oct 17, 2026

Copy link
Copy Markdown
Member Author

Merged by squash at reviewed head 9344fe78eae237f3c04b92dcf23632f672862af1 as 4e7ef1e1. The gates were met on that SHA:

  • independent review CLEAN, posted above (carried across rebases by identical git range-diff)
  • local verification posted above
  • CI green on 9344fe78
  • labels mirrored; no unresolved threads

CR waived: quota, adversarial review + local verification + green CI. A retrospective CodeRabbit review will run when quota returns. Refs #227 (items 4-5 follow after #493).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/s Hours impact/internal Team-internal only priority/p3 Polish / idea / may never ship severity/low Minor harm triaged Item has been triaged type/chore Maintenance / non-user-visible urgency/eventually No deadline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant