Add debugging to feed download process

Open
#1,860 0 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 2 days

@davidgamez is already working on this.

Since Oct 8, 2026.

Assessment

This issue has not been assessed yet.

Description

enhancement
Describe the problem
Description

A feed fails nightly in batch_process_dataset but succeeds when reproduced by hand, from a laptop and from a GCE VM running the exact production client (urllib3 + create_feed_ssl_context + same headers). IP blocking and TLS fingerprinting are ruled out. download_and_get_hash discards everything about the failed request; all we get is ValueError: Invalid HTTP response code: [N].

Proposed solution

1. Diagnostics in the shared download path: functions-python/helpers/utils.py

  • Capture per attempt: request headers, resolved URL, response headers, status code, latency, redirect chain, content type, is_zip, error type/message.
  • Sanitize before logging or storing: redact values for authorization, cookie, x-api-key, token, and any header or query param matching the feed's api_key_parameter_name; strip URL userinfo. Names kept, values redacted.
  • Capture external IP on the failure path, cached per process.
  • download_feed(..., max_bytes=None) raises FeedDownloadError carrying the diagnostics. download_and_get_hash keeps its current signature and return value.
  • build_feed_request_params falls back to default headers when the config DB is unreachable.

2. Persist failures: gtfs_feed_availability_check

  • Liquibase changeset adding nullable source, request_headers, response_headers, redirect_urls, external_ip, resolved_url. Backfill existing rows to source='availability_check'.
  • batch_process_dataset writes one row with source='dataset_download' on download failure.

3. Operations endpoint: POST /v1/operations/gtfs_feeds/{id}/download_debug

  • Runs the download through the same shared functions and returns the diagnostics.
  • max_bytes cap (~50MB).
  • Spec in docs/OperationsAPI.yaml, impl in feeds_operations_impl.py.

4. Local script: scripts/download-verifier.sh --url <url>

  • Self-sufficient, same conventions as function-python-run.sh: symlinks shared code, builds venv, runs the verifier.
  • download_verifier.py gains --url / --feed_id / --skip-upload, replacing the hardcoded PRODUCER_URL, and passes the real feed id to download_content.
Alternatives you've considered

No response

Additional context

No response

Dominant language
Python
Stars
34
Forks
7
Avg merge
2d 22h
Merged PRs (30d)
21

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from MobilityData/mobility-feed-api

All issues in MobilityData/mobility-feed-api

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.