Skip to content

fix(billing-cost-management-mcp-server): let botocore reject a non-string billing period start - #4992

Merged
finklen-amazon merged 2 commits into
mainfrom
fix/bcm-bc-period-type
Nov 3, 2026
Merged

finklen-amazon merged 2 commits into
mainfrom
fix/bcm-bc-period-type

Conversation

@finklen-amazon

Copy link
Copy Markdown
Contributor

Fixes a regression from #4939.

Summary

Changes

  • billing-conductor, get-billing-group-cost-report: the future-month check added in fix(billing-cost-management-mcp-server): reject or flag future Billing Conductor billing periods #4939 ran re.fullmatch on InclusiveStartBillingPeriod from the caller's billing_period_range JSON. A non-empty non-string value (for example 202701, an object, or true) raised TypeError before any request; empty ones such as 0 or {} already fell through to botocore. _is_future_billing_period now returns False for any non-string value, as its docstring already said for malformed input, so botocore rejects the request with its usual ParamValidationError.
  • procurement-preferences tests: the list tests used the Get-shaped sample_preference fixture, which carries EinvoiceDeliveryPreference, a field list summaries never return. They now use a sample_preference_summary fixture built from ProcurementPortalPreferenceSummary members, checked against the botocore model. Get tests are unchanged. Test-only.

No tool parameter, description or success response changes.

User experience

get-billing-group-cost-report with billing_period_range={"InclusiveStartBillingPeriod": 202701, "ExclusiveEndBillingPeriod": "2026-11"}:

  • Before: error_type: unknown_typeerror, retry_strategy: do_not_retry, message: "expected string or bytes-like object".
  • After: error_type: validation_error, boto_error_type: ParamValidationError, retry_strategy: modify_request, and a message that names BillingPeriodRange.InclusiveStartBillingPeriod and its type. No request is sent.

String starts behave as before: a future month is still refused locally, and current, past and malformed strings are sent to the service.

Testing

  • New unit tests: _is_future_billing_period returns False for int, dict, list and bytes, and get_billing_group_cost_report with an int, object or boolean start returns the ParamValidationError from a real botocore client, with a before-send hook proving that nothing is sent. 7 of the 15 tests selected fail on main (the 7 new cases); the other 8 are existing regression guards. The fixture check is a regression guard and passes on main.
  • Billing Conductor and procurement-preferences test files: 303 passed; ruff check, ruff format --check and pyright are clean.
  • Live check against a real account, calling the served tools over stdio: 11/11 pass on this branch and 7/11 on main. The 4 failures on main are the int and object start cases. The controls (a string start reaches the service; a future string start is still refused locally) and the procurement-preferences list shape checks pass on both.

Checklist

If your change doesn't seem to apply, please leave them unchecked.

  • I have reviewed the contributing guidelines
  • I have performed a self-review of this change
  • Changes have been tested
  • Changes are documented

Is this a breaking change? (Y/N) N

RFC issue number:

Checklist:

  • Migration process documented
  • Implement warnings (if it can live side by side)

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.

…ring billing period start

get-billing-group-cost-report checks InclusiveStartBillingPeriod for a
future month before calling the service. A non-empty non-string value
parsed from billing_period_range (for example 202701, an object or
true) reached re.fullmatch and raised TypeError, so the caller got
unknown_typeerror / do_not_retry and no hint about the bad field.

_is_future_billing_period now returns False for any non-string value,
as its docstring already promised for malformed input. botocore then
rejects the request before sending it with a ParamValidationError that
names BillingPeriodRange.InclusiveStartBillingPeriod and its type,
returned as validation_error / modify_request.

Tests: the period check returns False for int, dict, list and bytes,
and get_billing_group_cost_report with an int, object or boolean start
returns the ParamValidationError without sending a request.
…e for procurement preference list tests

The list tests used the Get-shaped sample_preference fixture, which
carries EinvoiceDeliveryPreference, a field ListProcurementPortalPreferences
summaries never return. Add a sample_preference_summary fixture built from
ProcurementPortalPreferenceSummary members (plus the shared secret, to
keep exercising the defensive list redaction), switch the list and
list-routing tests to it, and check the fixture against the botocore
model. Get tests keep sample_preference.
@codecov

codecov Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.79%. Comparing base (69e2666) to head (6a7e164).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4992   +/-   ##
=======================================
  Coverage   93.79%   93.79%           
=======================================
  Files        1080     1080           
  Lines       94712    94714    +2     
  Branches    15442    15443    +1     
=======================================
+ Hits        88833    88835    +2     
  Misses       3505     3505           
  Partials     2374     2374           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@finklen-amazon
finklen-amazon added this pull request to the merge queue Nov 3, 2026
Merged via the queue into main with commit 5fa8de7 Nov 3, 2026
209 checks passed
@finklen-amazon
finklen-amazon deleted the fix/bcm-bc-period-type branch November 3, 2026 20:33
@github-project-automation github-project-automation Bot moved this from To triage to Done in awslabs/mcp Project Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants