Repository navigation
fix(billing-cost-management-mcp-server): send filter for getTagsOrValues and getCostCategories - #4970
Merged
finklen-amazon merged 1 commit intoNov 2, 2026
Conversation
finklen-amazon
requested review from
a team,
Comusus,
Dinkie,
Rahul-1404,
anniewn,
bhatia-di,
callnmm,
chittev,
johnwangwyx,
junaidgirkar,
mattkelsey,
shsrams,
somsubhro,
wangyuhere and
yasmeenh11
as code owners
October 30, 2026 18:45
bhatia-di
previously approved these changes
Oct 30, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4970 +/- ##
=======================================
Coverage 93.79% 93.79%
=======================================
Files 1080 1080
Lines 94692 94703 +11
Branches 15438 15440 +2
=======================================
+ Hits 88812 88823 +11
Misses 3505 3505
Partials 2375 2375 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
anniewn
previously approved these changes
Oct 30, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Oct 30, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Oct 30, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Oct 30, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Oct 30, 2026
finklen-amazon
force-pushed
the
fix/bcm-ce-tags-categories-filter
branch
from
November 2, 2026 00:46
92e08ec to
394396c
Compare
Dinkie
previously approved these changes
Nov 2, 2026
…ues and getCostCategories cost-explorer accepted `filter` for getTagsOrValues and getCostCategories but never sent it, so a filtered call returned the unfiltered list as a success. Both APIs take Filter and apply it: the lists keep only the keys, names or values found on matching costs. - Forward filter to GetTags and GetCostCategories (keys and values). - Describe filter for both operations and their limit: an And of leaves only; Or, Not and a nested And are rejected by the service. - Extend the Tags leaves section and the response hint for a user: key or a group_by label to both operations: they now apply the filter, and there too a user: key with Values matches nothing (with ABSENT, every cost). Both also reject an empty Tags key, like getDimensionValues. - Treat filter '""' (or a blank JSON string) as empty, like ''. - cost-comparison: call a blank filter empty, before creating the client. - group_by '[]' means no grouping on operations without GroupBy, as it does in getCostAndUsage. A group_by that is not JSON is still rejected there as not supported.
finklen-amazon
force-pushed
the
fix/bcm-ce-tags-categories-filter
branch
from
November 2, 2026 17:13
394396c to
3dea6e0
Compare
finklen-amazon
enabled auto-merge
November 2, 2026 17:14
Dinkie
approved these changes
Nov 2, 2026
Dinkie
approved these changes
Nov 2, 2026
wangyuhere
approved these changes
Nov 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes
Summary
Changes
cost-explorernow sendsfilterforgetTagsOrValuesandgetCostCategories.Both operations accepted
filterbut never sent it, so a filtered call returned the whole, unfiltered list asstatus: success. GetTags and GetCostCategories both takeFilterand apply it: the lists keep only the tag keys, tag values, cost category names or category values found on costs that match it.filteris now forwarded asFilterfor tag keys, a tag key's values (tag_key), category names, and a category's values (cost_category_name). An empty filter is rejected before any AWS call, as for the other operations.filteras optional for both operations, says what it does there, and adds both to the "Limits by operation" line: anAndof leaves only (anAndinside it is rejected);OrandNotare rejected. ThegetDimensionValuesline gets the same nested-Andcorrection.user:prefix or a TAGgroup_bylabel (from fix(billing-cost-management-mcp-server): document the cost-explorer Tags filter format and hint on tag keys that cannot match #4941), now also covergetTagsOrValuesandgetCostCategories. Now that they apply the filter, auser:key withValuessilently empties their lists too (withABSENTit matches every cost).Small fixes in the same filter and
group_byvalidation:filter='""'(an empty JSON string), or a blank one such as'" "', is now "filter is empty", like'', instead of a botocore type error. Other JSON scalars are still left to the SDK.cost-comparison: a whitespace-only filter now says "filter is empty" instead of "Invalid JSON format", and an empty filter is rejected before the Cost Explorer client is created.group_by='[]'(or'null') on an operation without GroupBy is now "no grouping", asgetCostAndUsagereads it, instead of avalidation_error. A non-emptygroup_byis still rejected, and so is one that is not JSON (e.g.'SERVICE'), with the same "group_by is not supported" error as onmain.User experience
Before:
{"operation": "getCostCategories", "filter": "{\"Dimensions\": {\"Key\": \"REGION\", \"Values\": [\"no-such-region-1\"]}}"}returnedstatus: successwith every category name.After: the same call returns an empty
CostCategoryNames, and a real filter such asSERVICE = Amazon Elastic Kubernetes Servicereturns only the names (or tag keys) on that service's costs.{"filter": "{\"Or\": [...]}"}now returns the service'sValidationException("Or expression is not allowed ...") instead of a silent unfiltered success.Merge conflict
Rebased on
mainafter #4941, which documented the Tags filter format and added a hint for Tags keys that cannot match, in the same function and description as this change. The only textual conflict was the import block oftools/cost_explorer_tools.py(#4941 addedimport json; this PR splits theaws_service_baseimport to addparse_json); both were kept. Because this PR makesgetTagsOrValuesandgetCostCategoriesapplyfilter, #4941's Tags section and hint were extended to them (see Changes), after checking each of that section's claims live on both operations.A second rebase, after #4987, conflicted in the same places: #4987 extended that section, the hint's docstring and the hint tests to
getCostAndUsageWithResources, and added an empty-key line. Both are kept. The section heading and docstring now list all five operations, the hint tests keep both sides' cases, andgetTagsOrValuesandgetCostCategorieswere added to the operations that reject an empty Tags key (checked live: an empty key with or without a value returnsValidationException; #4987's 6,000-value limit also holds for both).Testing
All commands run from
src/billing-cost-management-mcp-server.uv run --frozen pytest: 4427 passed.ruff format --check,ruff check,pyrightandpre-commitare clean. Every changed source line is covered.main, except 2 regression guards (noFilteris sent whenfilteris omitted). The tests added with the rebase were shown failing before their fix:group_bythat is not JSON or is blank on each of the six operations, the blank quoted filter, the Tags hint ongetTagsOrValuesandgetCostCategories(keys and values), and the extended description.user:tag key):main(negative control:Or,Notand{}returnsuccessthere because the filter never reaches AWS).getTagsOrValuesandgetCostCategories: 29/29 on this branch; 8/29 onmain, where the filter is ignored (and 16/23 of the first 23 before the hint and section were extended: the data claims held, the hint and description claims failed). Auser:key with a value returned an empty list on both operations where the bare key returned a non-empty one;ABSENTon auser:key returned the whole list; another case of key or value matched nothing;Values: [""]returned the same list asABSENT; anaws:key with a value matched; an empty key and 6,001 values were rejected.Not/Andaround auser:key and the values modes) and found no contradiction.Checklist
If your change doesn't seem to apply, please leave them unchecked.
Is this a breaking change? (Y/N) N. A
filterthat was silently ignored is now applied; no parameter or tool is renamed or removed.RFC issue number:
Checklist:
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.