Skip to content

fix(auto_source): pin request budget for token-based auto-source feeds - #1062

Merged
gildesmarais merged 2 commits into
mainfrom
fix/auto-source-max-requests
Aug 10, 2026
Merged

fix(auto_source): pin request budget for token-based auto-source feeds#1062
gildesmarais merged 2 commits into
mainfrom
fix/auto-source-max-requests

Conversation

@gildesmarais

Copy link
Copy Markdown
Member

html2rss-web calls Html2rss.feed (not Html2rss.auto_source), so the gem method-level max_requests default of 4 does not apply here. Without this change, token-backed auto-source feeds inherit Policy::DEFAULTS[:max_requests]=1, blocking sitemap sub-fetches. Pins max_requests=4 explicitly in token_generator_input. No breaking change.

Explicitly set max_requests=4 in token_generator_input to match the
html2rss gem auto_source default. Previously the gem policy default
of 1 prevented sitemap sub-fetches from firing.

No breaking change: requests beyond 1 previously returned empty feeds.
Comment thread app/web/feeds/source_resolver.rb Outdated
Co-authored-by: Gil Desmarais <gildesmarais@users.noreply.github.com>
@gildesmarais gildesmarais changed the title fix(auto-source): pin request budget for token-based auto-source feeds fix(auto_source): pin request budget for token-based auto-source feeds Aug 10, 2026
@gildesmarais
gildesmarais enabled auto-merge (squash) August 10, 2026 15:02
@gildesmarais
gildesmarais merged commit b083d83 into main Aug 10, 2026
14 of 15 checks passed
@gildesmarais
gildesmarais deleted the fix/auto-source-max-requests branch August 10, 2026 15:03
gildesmarais added a commit to html2rss/html2rss that referenced this pull request Aug 10, 2026
…uests` to 4 (#411)

## Summary

Adds sitemap index (`sitemapindex`) discovery and fan-out support to
auto-source (e.g. `github.blog`, Yoast SEO-generated sitemaps, YC blog).

### Background & Context
1. **Sitemap Index Support**: Many modern sites serve a
`sitemap_index.xml` containing `<sitemap><loc>` elements pointing to
sub-sitemaps (e.g., `post-sitemap.xml`) rather than direct `<url><loc>`
elements. `Discovery::Sitemap` previously parsed flat `<urlset>`
documents, returning `[]` for index documents.
2. **Request Budget for Auto Mode**: `auto_source` defaulted to
`max_requests: 1` (inherited from `Policy::DEFAULTS`), which prevented
follow-up sub-sitemap HTTP fetches from executing out of the box.

---

## New Capabilities & Changes

- **`Discovery::Sitemap`**
([lib/html2rss/auto_source/discovery/sitemap.rb](file:///Users/gil/versioned/html2rss/html2rss/lib/html2rss/auto_source/discovery/sitemap.rb)):
- Returns a `Result` value object (`entries:` and `sub_sitemap_urls:`).
- Automatically detects `<sitemapindex>` documents and extracts child
sitemap URLs in document order (naturally prioritizing post/news
sitemaps).

- **`Scraper::Sitemap`**
([lib/html2rss/auto_source/scraper/sitemap.rb](file:///Users/gil/versioned/html2rss/html2rss/lib/html2rss/auto_source/scraper/sitemap.rb)):
- Implements fan-out through `sub_sitemap_urls` up to `MAX_SUB_SITEMAPS
= 3`.
- Catches `RequestBudgetExceeded` gracefully to log an operational
warning and yield all accumulated entries without crashing.

- **`Html2rss.auto_source` & `auto_json_feed`**
([lib/html2rss.rb](file:///Users/gil/versioned/html2rss/html2rss/lib/html2rss.rb)):
- Defaults `max_requests: 4` for auto-sourcing (1 initial page + 1 root
sitemap + up to 2 sub-sitemaps), while keeping the conservative
`max_requests: 1` policy default for explicit feed configs.

---

## Verification

- **RSpec**: 1,156/1,156 unit tests passing (0 failures). Added test
coverage for sitemapindex parsing, scraper fan-out, `MAX_SUB_SITEMAPS`
capping, and budget exhaustion.
- **RuboCop**: 255 files inspected, 0 offenses detected.
- **YARD Lint**: 100% documentation coverage.
- **Quality Gate**: `make ready` passed with exit code 0.

---

## Related
- Paired with `html2rss-web` PR: html2rss/html2rss-web#1062
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.

1 participant