Skip to content

fix: improve harvest reliability across repositories - #256

Open
jorgitogb wants to merge 7 commits into
mainfrom
fix/openagrar-graceful-skip
Open

jorgitogb wants to merge 7 commits into
mainfrom
fix/openagrar-graceful-skip

Conversation

@jorgitogb

@jorgitogb jorgitogb commented Aug 18, 2026

Copy link
Copy Markdown
Contributor
  • Handle doi as array in publisso jq script
  • Treat HttpSessionTechnicalError as recoverable per-dataset error
  • Retry on 5xx with backoff + reduce edal concurrency
  • Log failed URLs to output/failed_entries.jsonl
  • Gracefully skip openagrar when Cloudflare challenge detected
  • Add configurable User-Agent to HttpSession

The publisso jq script failed with 'string and array cannot be added'
when the doi field was an array instead of a string. This caused the
entire publisso repo to report a jq error and lose data.

Fixed by checking type before string concatenation in two places:
- Line 8: @id construction
- Line 23: identifier value and url construction
The edal repository (335 URLs) had many URLs returning 500/503/timeout
errors from the IPK server. Previously, HttpSessionTechnicalError was not
caught in _extract_metadata, causing the entire repo to be skipped.

Now catches HttpSessionTechnicalError alongside HttpSessionResponseError
and HttpSessionDecodeError, treating server errors as recoverable
per-dataset failures instead of unrecoverable repo-wide errors.

Result: edal now returns ~299 valid entries instead of 0 (skipped).
Root cause: IPK server (doi.ipk-gatersleben.de) rate-limits under
concurrent requests, returning transient 503s. With connection_limit
20 and no retry logic, ~54% of edal URLs failed per run.

Changes:
- get_decoded_url: retry up to 3x with exponential backoff + jitter
  on 5xx/network/timeout errors (transient). 4xx permanent, no retry.
- Set raise_for_status=False so explicit status checks are effective.
- edal per-repo http_client: connection_limit 4 (gentler on server).
- Added 3 new tests: retry-then-succeed, retry-exhausts, no-retry-404.

Verified: sequential requests all succeed; 20 concurrent = 25% fail;
4 concurrent = 0% fail. Retry covers transient spikes.
Set default User-Agent header to 'FAIRagro-Harvester/1.0 (harvestmaster@fairagro.net)'.
All HTTP requests now identify as FAIRagro bot instead of default aiohttp UA.
User-Agent is configurable via HttpSessionConfig.user_agent field.
@jorgitogb jorgitogb changed the title feat: add configurable User-Agent to HttpSession fix: improve harvest reliability across repositories Aug 18, 2026
- Add encoding='utf-8' to open() call (W1514)
- Wrap long lines in metadata_scraper (C0301)
- Remove trailing whitespace in openagrar.py (C0303)
- Extract _fetch_http and _read_file helpers from get_decoded_url (R0912, R0915)
- Remove redundant except HttpSessionResponseError: raise (W0706)
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