Skip to content

fix(cloudwatch-mcp-server): make storedBytes optional in LogGroupMetadata#2872

Open
mtmtcode wants to merge 3 commits intoawslabs:mainfrom
mtmtcode:fix/cloudwatch-describe-log-groups-stored-bytes
Open

fix(cloudwatch-mcp-server): make storedBytes optional in LogGroupMetadata#2872
mtmtcode wants to merge 3 commits intoawslabs:mainfrom
mtmtcode:fix/cloudwatch-describe-log-groups-stored-bytes

Conversation

@mtmtcode
Copy link
Copy Markdown

@mtmtcode mtmtcode commented Apr 6, 2026

Summary

  • Make storedBytes field optional in LogGroupMetadata model to match AWS API behavior
  • AWS DescribeLogGroups API may omit storedBytes for log groups where storage size has not been calculated yet
  • This caused a Pydantic validation error (Field required [type=missing]), breaking the entire describe_log_groups tool response

Changes

  • src/cloudwatch-mcp-server/awslabs/cloudwatch_mcp_server/cloudwatch_logs/models.py: Changed storedBytes: int = Field(...) to storedBytes: Optional[int] = Field(default=None, ...), consistent with other optional fields like retentionInDays and kmsKeyId in the same model
  • tests/cloudwatch_logs/test_logs_models.py: Added tests verifying LogGroupMetadata handles both missing and present storedBytes

Checklist

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

Test plan

  • All existing 371 tests pass
  • New tests verify storedBytes defaults to None when omitted
  • New tests verify storedBytes is correctly set when provided

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.

mtmtcode and others added 2 commits April 6, 2026 19:22
…data

AWS DescribeLogGroups API may not return storedBytes for log groups
where storage size has not been calculated yet. This caused a Pydantic
validation error, breaking the entire describe_log_groups tool response.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Verify LogGroupMetadata handles missing and present storedBytes correctly,
matching the AWS DescribeLogGroups API behavior.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mtmtcode mtmtcode marked this pull request as ready for review April 6, 2026 10:35
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.37%. Comparing base (7b6c0d8) to head (7e68fda).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2872   +/-   ##
=======================================
  Coverage   91.37%   91.37%           
=======================================
  Files        1014     1014           
  Lines       74946    74946           
  Branches    12044    12044           
=======================================
  Hits        68484    68484           
  Misses       3990     3990           
  Partials     2472     2472           

☔ View full report in Codecov by Sentry.
📢 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.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To triage

Development

Successfully merging this pull request may close these issues.

1 participant