Skip to content

fix(tests): read integration test API key from LANDINGAI_API_KEY secret - #271

Merged
hrnn merged 2 commits into
mainfrom
fix/api-key-from-env-secret
Aug 13, 2026
Merged

fix(tests): read integration test API key from LANDINGAI_API_KEY secret#271
hrnn merged 2 commits into
mainfrom
fix/api-key-from-env-secret

Conversation

@hrnn

@hrnn hrnn commented Aug 13, 2026

Copy link
Copy Markdown
Member

What

The e2e predict tests carried a hardcoded LandingLens API key at the top of
tests/integration/landingai/test_predict_e2e.py. This reads it from the
LANDINGAI_API_KEY environment variable instead, populated in CI from the
repository secret of the same name.

Why

CI has been red since the hardcoded key stopped resolving to a user record —
all five live-endpoint tests failed with 401 UNAUTHORIZED
(Failed to find user record with apiKey: land_sk_aMemW***), which cancelled
the whole 12-job matrix and blocked Release. With the key in source there was
no way to rotate it without a code change.

Fork PRs

Repository secrets are not exposed to workflow runs triggered by pull requests
from forks, and this repo is public with 59 of them. So the tests skip
themselves when the key is empty rather than failing with a 401 that external
contributors cannot act on:

5 skipped   # LANDINGAI_API_KEY unset
5 passed    # LANDINGAI_API_KEY set

Both paths verified locally against the live endpoints.

hrnn added 2 commits August 13, 2026 14:30
The e2e predict tests carried a hardcoded LandingLens API key. Read it from
the LANDINGAI_API_KEY environment variable instead, populated in CI from the
repository secret of the same name.

Secrets are not exposed to workflow runs triggered by pull requests from
forks, so the tests skip themselves when the key is absent rather than
failing with a 401.
Exporting LANDINGAI_API_KEY for the whole pytest run leaks it into the unit
tests that cover credential loading. Environment variables take precedence
over .env files, so those tests read the real key instead of the one they set
up, and the tests asserting that a missing or invalid key raises found a valid
one instead.

Clear the credential env vars before each unit test. Tests that need a
credential still set it themselves.
@hrnn
hrnn enabled auto-merge (squash) August 13, 2026 18:57
@hrnn
hrnn disabled auto-merge August 13, 2026 19:05
@Kelly-Castrillon
Kelly-Castrillon requested a balanced review from Copilot August 13, 2026 19:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Moves live integration-test authentication from a hardcoded key to a rotatable CI secret.

Changes:

  • Reads LANDINGAI_API_KEY from the environment.
  • Skips live tests when the secret is unavailable.
  • Isolates unit tests from ambient credentials.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
.github/workflows/ci_cd.yml Supplies the repository secret to pytest.
tests/integration/landingai/test_predict_e2e.py Loads the key from the environment and skips when absent.
tests/unit/conftest.py Clears ambient credential variables for unit tests.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@Kelly-Castrillon Kelly-Castrillon left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

@hrnn
hrnn merged commit 9ed58c9 into main Aug 13, 2026
9 of 13 checks passed
@hrnn
hrnn deleted the fix/api-key-from-env-secret branch August 13, 2026 19:41
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.

3 participants