Skip to content

fix: SDK audit — correctness fixes and improved drift detection - #15

Merged
amitray007 merged 3 commits into
masterfrom
release/sdk-audit-2026-03-23
Mar 23, 2026
Merged

fix: SDK audit — correctness fixes and improved drift detection#15
amitray007 merged 3 commits into
masterfrom
release/sdk-audit-2026-03-23

Conversation

@amitray007

Copy link
Copy Markdown
Owner

Summary

  • Fix holiday enum path param bug — update_holiday_preferences() now extracts .value from enum types before URL interpolation
  • Fix production_partner_ids type from Optional[int] to Optional[List[int]] in CreateDraftListingRequest
  • Fix image_ids type from Optional[List[str]] to Optional[List[int]] in UpdateListingRequest
  • Add variation_images to mandatory list in UpdateVariationImagesRequest
  • Add regression tests for enum path param and mandatory validation
  • Fix MOCK_HOLIDAY_ID from string to integer for realistic testing
  • Overhaul maintenance-check workflow with severity classification (severity: high/medium/low), assignee, and structured issue bodies

Closes #14

Test plan

  • All 233 tests pass (2 new tests added)
  • Verify severity: high, severity: medium, severity: low labels created on first workflow run
  • Trigger manual workflow dispatch to validate issue creation format

🤖 Generated with Claude Code

amitray007 and others added 3 commits March 23, 2026 19:53
…ation

- Fix holiday_id enum not extracted in URL path (HolidayPreferences)
- Fix production_partner_ids type from int to List[int] (CreateDraftListingRequest)
- Fix image_ids type from List[str] to List[int] (UpdateListingRequest)
- Add variation_images to mandatory list (UpdateVariationImagesRequest)
- Update spec baseline

Closes #14

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Change MOCK_HOLIDAY_ID from string to integer to match API contract
- Add test for enum path param extraction in update_holiday_preferences
- Add negative test for UpdateVariationImagesRequest mandatory validation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Auto-classify drift as high/medium/low based on audit findings
- Title format: "audit: Spec Drift [date] — [severity]"
- Add severity labels (high, medium, low) with auto-creation
- Assign issues to @amitray007
- Show actionable items extracted from audit, not just raw reports
- Include structured SDK impact section (missing endpoints, body drift, etc.)
- Severity-specific action guidance in issue body

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 23, 2026 16:31
@amitray007 amitray007 self-assigned this Mar 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Test Coverage Report

Overall: 93% (1533/1643 statements covered)

Coverage by file
File Statements Missing Coverage
etsy_python/v3/auth/OAuth.py 33 33 0%
etsy_python/v3/auth/__init__.py 1 1 0%
etsy_python/v3/enums/Language.py 12 12 0%
etsy_python/v3/enums/ListingInventory.py 3 3 0%
etsy_python/v3/models/ProcessingProfile.py 21 10 52%
etsy_python/v3/models/ShopReturnPolicy.py 25 11 56%
etsy_python/v3/resources/ProcessingProfile.py 26 11 58%
etsy_python/v3/models/HolidayPreferences.py 8 2 75%
etsy_python/v3/models/Miscellaneous.py 8 2 75%
etsy_python/v3/common/Utils.py 31 4 87%
etsy_python/v3/exceptions/RequestException.py 8 1 88%
etsy_python/v3/resources/Response.py 9 1 89%
etsy_python/v3/exceptions/BaseAPIException.py 10 1 90%
etsy_python/v3/models/Request.py 22 2 91%
etsy_python/v3/resources/Listing.py 81 6 93%
etsy_python/v3/models/Listing.py 148 9 94%
etsy_python/v3/resources/Session.py 94 1 99%
etsy_python/__init__.py 2 0 100%
etsy_python/_version.py 1 0 100%
etsy_python/v3/common/Env.py 10 0 100%
etsy_python/v3/common/Request.py 3 0 100%
etsy_python/v3/enums/HolidayPreferences.py 29 0 100%
etsy_python/v3/enums/Listing.py 77 0 100%
etsy_python/v3/enums/ProcessingProfile.py 7 0 100%
etsy_python/v3/enums/ShippingProfile.py 261 0 100%
etsy_python/v3/enums/ShopReceipt.py 12 0 100%
etsy_python/v3/exceptions/__init__.py 2 0 100%
etsy_python/v3/models/FileRequest.py 7 0 100%
etsy_python/v3/models/Product.py 7 0 100%
etsy_python/v3/models/Receipt.py 18 0 100%
etsy_python/v3/models/ShippingProfile.py 85 0 100%
etsy_python/v3/models/Shop.py 24 0 100%
etsy_python/v3/models/Utils.py 19 0 100%
etsy_python/v3/models/__init__.py 10 0 100%
etsy_python/v3/resources/HolidayPreferences.py 19 0 100%
etsy_python/v3/resources/ListingFile.py 22 0 100%
etsy_python/v3/resources/ListingImage.py 22 0 100%
etsy_python/v3/resources/ListingInventory.py 18 0 100%
etsy_python/v3/resources/ListingOffering.py 12 0 100%
etsy_python/v3/resources/ListingProduct.py 12 0 100%
etsy_python/v3/resources/ListingTranslation.py 19 0 100%
etsy_python/v3/resources/ListingVariationImages.py 16 0 100%
etsy_python/v3/resources/ListingVideo.py 22 0 100%
etsy_python/v3/resources/Miscellaneous.py 16 0 100%
etsy_python/v3/resources/Payment.py 23 0 100%
etsy_python/v3/resources/PaymentLedgerEntry.py 15 0 100%
etsy_python/v3/resources/Receipt.py 25 0 100%
etsy_python/v3/resources/ReceiptTransactions.py 27 0 100%
etsy_python/v3/resources/Review.py 16 0 100%
etsy_python/v3/resources/ShippingProfile.py 58 0 100%
etsy_python/v3/resources/Shop.py 23 0 100%
etsy_python/v3/resources/ShopProductionPartner.py 11 0 100%
etsy_python/v3/resources/ShopReturnPolicy.py 28 0 100%
etsy_python/v3/resources/ShopSection.py 25 0 100%
etsy_python/v3/resources/Taxonomy.py 23 0 100%
etsy_python/v3/resources/User.py 14 0 100%
etsy_python/v3/resources/UserAddress.py 19 0 100%
etsy_python/v3/resources/__init__.py 29 0 100%
etsy_python/v3/resources/enums/RateLimit.py 8 0 100%
etsy_python/v3/resources/enums/Request.py 7 0 100%

Updated by PR Tests

@amitray007
amitray007 merged commit 1a34957 into master Mar 23, 2026
9 checks passed
@amitray007
amitray007 deleted the release/sdk-audit-2026-03-23 branch March 23, 2026 16:34

Copilot AI left a comment

Copy link
Copy Markdown

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 applies a set of SDK correctness fixes identified during a spec/SDK audit, adds targeted regression tests, and refactors the GitHub maintenance-check workflow to generate drift issues with severity classification.

Changes:

  • Fix path-param interpolation for holiday enum IDs and add a regression test.
  • Correct several request-model field types / validation rules and add a mandatory-field regression test.
  • Update the maintenance-check workflow to classify drift severity and create structured issues/labels/assignees.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
etsy_python/v3/resources/HolidayPreferences.py Extract enum .value for holiday_id before URL interpolation.
etsy_python/v3/models/Listing.py Fix request model typings and enforce variation_images as mandatory.
tests/test_remaining_resources.py Add regression test ensuring enum holiday IDs interpolate correctly in endpoint path.
tests/test_listing_models.py Add regression test for mandatory validation on UpdateVariationImagesRequest.
tests/fixtures/responses.py Make holiday fixture data more realistic (numeric ID, updated name).
tests/conftest.py Update MOCK_HOLIDAY_ID to numeric ID to match API expectations.
specs/baseline.json Sync baseline spec text with latest spec (description formatting).
.github/workflows/maintenance-check.yml Add severity classification, label management, and structured issue creation/update logic.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -1,4 +1,5 @@
from dataclasses import dataclass
from enum import Enum
from typing import Optional, Union

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

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

Optional is no longer used in this module after removing Optional[...] from the holiday_id type hint. Please drop the unused import to avoid lint/type-check noise.

Suggested change
from typing import Optional, Union
from typing import Union

Copilot uses AI. Check for mistakes.
if [ -f "$DIFF_FILE" ]; then
# Count sections that have content (not just "No ... endpoints/changes")
if ! grep -q "No new endpoints" "$DIFF_FILE"; then
NEW_ENDPOINTS=$(grep -c '^\- \*\*' "$DIFF_FILE" 2>/dev/null || echo 0)

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

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

The NEW_ENDPOINTS counter is computed by grepping for - ** across the entire diff report, which will also count bullets in other sections (Removed Endpoints, Schema Changes, Deprecations). This can inflate the “new endpoints” count and summary; consider scoping the count to just the “## New Endpoints” section (e.g., by extracting that section first).

Suggested change
NEW_ENDPOINTS=$(grep -c '^\- \*\*' "$DIFF_FILE" 2>/dev/null || echo 0)
NEW_ENDPOINTS=$(sed -n '/^## New Endpoints$/,/^## /p' "$DIFF_FILE" | grep -c '^\- \*\*' 2>/dev/null || echo 0)

Copilot uses AI. Check for mistakes.
if [ "$REMOVED_ENDPOINTS" -gt 0 ] || [ "$MISSING_ENDPOINTS" -gt 0 ] || [ "$BODY_DRIFT" -gt 0 ]; then
SEVERITY="high"
# Medium: new endpoints, changed endpoints, param drift, schema changes, real code issues
elif [ "$NEW_ENDPOINTS" -gt 0 ] || [ "$CHANGED_ENDPOINTS" -gt 0 ] || [ "$PARAM_DRIFT" -gt 0 ] || [ "$SCHEMA_CHANGES" -gt 0 ]; then

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

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

The severity logic comment says medium includes “real code issues”, but CODE_ISSUES is never used when computing SEVERITY. If code issues should bump severity, include a CODE_ISSUES > 0 check (or update the comment to reflect the intended behavior).

Suggested change
elif [ "$NEW_ENDPOINTS" -gt 0 ] || [ "$CHANGED_ENDPOINTS" -gt 0 ] || [ "$PARAM_DRIFT" -gt 0 ] || [ "$SCHEMA_CHANGES" -gt 0 ]; then
elif [ "$NEW_ENDPOINTS" -gt 0 ] || [ "$CHANGED_ENDPOINTS" -gt 0 ] || [ "$PARAM_DRIFT" -gt 0 ] || [ "$SCHEMA_CHANGES" -gt 0 ] || [ "$CODE_ISSUES" -gt 0 ]; then

Copilot uses AI. Check for mistakes.
Comment on lines +188 to +200
# Body drift (if any)
if ! grep -q "No request body drift" "$AUDIT_FILE"; then
echo "#### Request Body Drift"
sed -n '/## Request Body Drift/,/^## /p' "$AUDIT_FILE" | head -30
echo ""
fi

# Param drift (if any)
if ! grep -q "No query/path parameter drift" "$AUDIT_FILE"; then
echo "#### Parameter Drift"
sed -n '/## Query\/Path Parameter Drift/,/^## /p' "$AUDIT_FILE" | head -30
echo ""
fi

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

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

These sed -n '/## Request Body Drift/,/^## /p' (and similar) ranges will stop immediately because the end pattern ^## matches the same header line as the start pattern. As a result the issue body will include only the section header, not the section content. Use an end pattern that matches the next specific section header (or a range that excludes the first ^## match).

Copilot uses AI. Check for mistakes.
Comment on lines +220 to +229
# Extra SDK methods
EXTRA_SECTION=$(sed -n '/## Extra SDK Methods/,/^## /p' "$AUDIT_FILE")
if ! echo "$EXTRA_SECTION" | grep -q "no matching OAS operation" || echo "$EXTRA_SECTION" | grep -q "\*\*"; then
echo "<details><summary>Extra SDK Methods (no OAS match)</summary>"
echo ""
echo "$EXTRA_SECTION" | head -20
echo ""
echo "</details>"
echo ""
fi

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

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

The EXTRA_SECTION extraction uses sed -n '/## Extra SDK Methods/,/^## /p', which will also stop on the start header and likely capture only a single line. This prevents the <details> block from containing the actual list; extract until the next known section header (e.g., “## Missing Exports”) instead.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

audit: Spec Drift [2026-03-23] — low

2 participants