Skip to content

feat: support feed stable ids as request parameter in the GBFS validator batch function#1306

Merged
davidgamez merged 2 commits intomainfrom
feat/gbfs_batch_feed_ids
Jul 31, 2025
Merged

feat: support feed stable ids as request parameter in the GBFS validator batch function#1306
davidgamez merged 2 commits intomainfrom
feat/gbfs_batch_feed_ids

Conversation

@davidgamez
Copy link
Copy Markdown
Member

@davidgamez davidgamez commented Jul 31, 2025

Summary:

This pull request enhances the gbfs_validator_batch function to support processing specific feeds based on a POST request with feed stable IDs, improves error handling, and adds corresponding unit tests. The most important changes include modifying the function signature, adding logic to handle feed IDs, introducing a helper function for fetching feeds by ID, and creating a new test case.

Enhancements to gbfs_validator_batch function:

  • Updated the function signature to accept a request parameter, enabling the function to process POST requests with a JSON body containing feed_ids. This allows selective feed processing or fallback to processing all feeds if no feed IDs are provided. (functions-python/gbfs_validator/src/main.py, [1] [2]
  • Added error handling for invalid or missing request bodies, ensuring the function gracefully handles malformed inputs. (functions-python/gbfs_validator/src/main.py, functions-python/gbfs_validator/src/main.pyL116-R133)

New helper function:

  • Introduced fetch_gbfs_feeds_by_stable_ids to query and retrieve GBFS feeds by their IDs, filtering out deprecated feeds. This modularizes the logic for feed retrieval by ID. (functions-python/gbfs_validator/src/main.py, functions-python/gbfs_validator/src/main.pyR169-R178)

Unit test additions:

  • Added a new test case, test_gbfs_validator_batch_by_feed_ids, to validate the behavior of the gbfs_validator_batch function when processing specific feed IDs. This test ensures proper handling of POST requests, feed retrieval, and publishing logic. (functions-python/gbfs_validator/tests/test_gbfs_validator.py, functions-python/gbfs_validator/tests/test_gbfs_validator.pyR182-R218)

Summary generated by our AI friend

Expected behavior:

When the batch function receives the feed_ids field in the post body, it only publishes events for the listed ids; otherwise, it will publish the events for all GBFS ids.

Testing tips:

(Internal team only)Deployed to DEV, this function can be tested by sending the command:

curl -X POST "https://gbfs-validator-batch-978785769226.northamerica-northeast1.run.app" \
-H "Authorization: bearer $(gcloud auth print-identity-token)" \
-H "Content-Type: application/json" \
-d '{
  "feed_stable_ids": [ "gbfs-lyon" ]
}'

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Run the unit tests with ./scripts/api-tests.sh to make sure you didn't break anything
  • Add or update any needed documentation to the repo
  • Format the title like "feat: [new feature short description]". Title must follow the Conventional Commit Specification(https://www.conventionalcommits.org/en/v1.0.0/).
  • Linked all relevant issues
  • Include screenshot(s) showing how this pull request works and fixes the issue(s)

@davidgamez davidgamez marked this pull request as ready for review July 31, 2025 18:53
@davidgamez davidgamez changed the title feat: support feed ids request parameter in the GBFS validator batch function feat: support feed stable ids as request parameter in the GBFS validator batch function Jul 31, 2025
@davidgamez davidgamez requested a review from cka-y July 31, 2025 19:14
Copy link
Copy Markdown
Contributor

@cka-y cka-y left a comment

Choose a reason for hiding this comment

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

LGTM! Follow up issue for GTFS?

@davidgamez
Copy link
Copy Markdown
Member Author

LGTM! Follow up issue for GTFS?

Great idea!

@davidgamez davidgamez merged commit bf22847 into main Jul 31, 2025
9 checks passed
@davidgamez davidgamez deleted the feat/gbfs_batch_feed_ids branch July 31, 2025 19:16
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.

2 participants