Skip to content

Conversation

@tjprescott
Copy link
Member

Fixes issue where elementId might be missing from comments.

Copilot AI review requested due to automatic review settings January 2, 2026 18:41
@tjprescott tjprescott added the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Jan 2, 2026
@tjprescott tjprescott self-assigned this Jan 2, 2026
@github-project-automation github-project-automation bot moved this to 🆕 New in APIView Jan 2, 2026
@tjprescott tjprescott moved this from 🆕 New to 👀In PR in APIView Jan 2, 2026
@tjprescott tjprescott added this to the Sprint 11: APIView and AVC milestone Jan 2, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an issue where Pydantic model instantiation would fail when certain fields (particularly ElementId) are missing from Cosmos DB query results. The fix adds explicit default=None to all Optional fields in the APIViewComment model, making them truly optional rather than required-but-nullable.

Key Changes:

  • Added default=None to eight Optional fields in APIViewComment model that previously lacked explicit defaults
  • Added test case test_metrics_report_missing_element_id to verify the fix handles missing fields gracefully

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/python-packages/apiview-copilot/src/_models.py Added default=None to Optional fields (id, review_id, api_revision_id, element_id, comment_text, created_by, created_on, comment_type) in the APIViewComment class to make them truly optional when deserializing from Cosmos DB
packages/python-packages/apiview-copilot/tests/metrics_test.py Added test case to verify metrics report generation doesn't fail when ElementId field is missing from comment dictionaries

@tjprescott
Copy link
Member Author

/check-enforcer evaluate

@tjprescott tjprescott merged commit 633cb6a into main Jan 9, 2026
16 checks passed
@github-project-automation github-project-automation bot moved this from 👀In PR to ✅ Done in APIView Jan 9, 2026
@tjprescott tjprescott deleted the copilot/FixMetrics branch January 9, 2026 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug This issue requires a change to an existing behavior in the product in order to be resolved.

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

3 participants