Skip to content

[ENH] Make missing GOOGLE_API_KEY a fatal error and update related components - #18

Open
markmikkelsen wants to merge 2 commits into
bids-standard:mainfrom
markmikkelsen:enh/bep-dashboard
Open

[ENH] Make missing GOOGLE_API_KEY a fatal error and update related components#18
markmikkelsen wants to merge 2 commits into
bids-standard:mainfrom
markmikkelsen:enh/bep-dashboard

Conversation

@markmikkelsen

Copy link
Copy Markdown
Collaborator

This pull request changes how the bids-schema collect bep-docs process handles missing or invalid Google Drive API keys. Previously, a missing or invalid GOOGLE_API_KEY would only log a warning and skip the collection phase, but now it is treated as a fatal error: the collector raises an exception and the run fails. This ensures that BEP Google Doc activity is always collected when required and that failures due to API key issues are surfaced clearly. The PR also updates documentation, error handling, and tests to reflect this stricter behavior.

Key changes:

Behavior and Error Handling:

  • The collector now raises a GoogleApiKeyError and fails the run if GOOGLE_API_KEY is missing or invalid, instead of logging a warning and skipping the phase. This applies to both missing keys and keys rejected by the Drive API (e.g., invalid, expired, or blocked). [1] [2] [3] [4] [5]
  • The CLI (bids_schema/cli.py) now catches GoogleApiKeyError and surfaces it as a click.ClickException for user-friendly error messages. [1] [2]

Documentation:

  • Updated .github/workflows/inject.yml, AGENTS.md, and code docstrings to document that a missing or invalid GOOGLE_API_KEY is now a fatal error, not a warning. [1] [2] [3]
  • Updated tools/inject-schema-fully-auto to fail fast with a clear error message if the API key is missing.

Testing:

  • Added and updated tests to verify that a missing or invalid API key causes GoogleApiKeyError to be raised, and that per-document permission errors are still handled gracefully. [1] [2]

These changes make the BEP Google Doc activity collection phase more robust and ensure that missing or invalid API credentials are surfaced immediately, preventing silent data staleness.

Previously, a missing or invalid GOOGLE_API_KEY was handled gracefully (logged a warning, exited 0). This changes the behavior so that a missing or Drive-API-rejected key raises `GoogleApiKeyError` and fails the run.

Per-doc 403/404s (e.g., a BEP doc that isn't link-shared) are still tolerated — only key-level errors are fatal. Updates docs, tests, CLI handlers, and the inject orchestrator accordingly.
@markmikkelsen markmikkelsen added the enhancement New feature or request label Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants