Skip to content

fix: Do not raise KeyError in parse_sitemap when partial options are provided#1940

Merged
vdusek merged 1 commit into
masterfrom
fix/sitemap-partial-options
Jun 4, 2026
Merged

fix: Do not raise KeyError in parse_sitemap when partial options are provided#1940
vdusek merged 1 commit into
masterfrom
fix/sitemap-partial-options

Conversation

@vdusek
Copy link
Copy Markdown
Collaborator

@vdusek vdusek commented Jun 3, 2026

Description

  • ParseSitemapOptions is declared as TypedDict(total=False), so every key is optional, but parse_sitemap read emit_nested_sitemaps, max_depth, and sitemap_retries with direct subscripting. Any caller passing a partial options dict (e.g. just timeout) via Sitemap.load(), Sitemap.parse(), or parse_sitemap() hit a KeyError.
  • Read all options uniformly with .get() and the existing defaults, collapsing the duplicated if/else branches.
  • Add a regression test covering a partial options dict.

…provided

ParseSitemapOptions is a TypedDict with total=False, so all keys are optional,
but parse_sitemap read three of them with direct subscripting, raising KeyError
for any partial options dict. Read all options with .get() and defaults instead.
@vdusek vdusek added t-tooling Issues with this label are in the ownership of the tooling team. adhoc Ad-hoc unplanned task added during the sprint. labels Jun 3, 2026
@vdusek vdusek self-assigned this Jun 3, 2026
@github-actions github-actions Bot added this to the 142nd sprint - Tooling team milestone Jun 3, 2026
@github-actions github-actions Bot added the tested Temporary label used only programatically for some analytics. label Jun 3, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.86%. Comparing base (dc1ed61) to head (8750236).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1940      +/-   ##
==========================================
+ Coverage   92.85%   92.86%   +0.01%     
==========================================
  Files         167      167              
  Lines       11714    11709       -5     
==========================================
- Hits        10877    10874       -3     
+ Misses        837      835       -2     
Flag Coverage Δ
unit 92.86% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vdusek vdusek requested a review from Mantisus June 3, 2026 17:59
@vdusek vdusek marked this pull request as ready for review June 3, 2026 17:59
Copy link
Copy Markdown
Collaborator

@Mantisus Mantisus left a comment

Choose a reason for hiding this comment

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

LGTM

@vdusek vdusek merged commit 8ab3f95 into master Jun 4, 2026
33 checks passed
@vdusek vdusek deleted the fix/sitemap-partial-options branch June 4, 2026 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants