Skip to content

OIDC token expires during flake evaluation, causing 401 on publish #275

Closed

Description

@flexiondotorg

What happens

After a successful flake evaluation, flakehub-push fails with a 401 Unauthorized when making its first API call to api.flakehub.com/token/status. The evaluation completes fine - it's the publish step that falls over.

Why it happens

The GitHub Actions OIDC JWT is acquired early in PushContext::from_cli_and_env(), before any Nix evaluation begins. The evaluation itself (nix flake show --all-systems + output path enumeration) can take 8+ minutes for large flakes. GitHub OIDC tokens are valid for roughly 5 minutes. By the time FlakeHubClient actually uses the token, it's already stale. There's no refresh logic to handle this gap.

Timeline from a real CI run

Time Event
01:43:21 OIDC token obtained, evaluation begins
01:51:50 First API call fails with 401 (~8 min later)

Suggested fix

Obtain the OIDC token after evaluation completes, just before constructing FlakeHubClient. Concretely: move get_actions_id_bearer_token() out of PushContext::from_cli_and_env() and call it in execute() before FlakeHubClient::new().

Alternatively, add token refresh logic before API calls - though deferring acquisition seems simpler and avoids the problem entirely.

Workaround

Setting my-flake-is-too-big: true reduces evaluation time enough to beat the token expiry, but sacrifices include-output-paths functionality (which is the whole reason we're doing the longer evaluation).

Reproduction

Failed CI run: https://github.com/wimpysworld/nix-config/actions/runs/22027542839/job/63647165419

Activity

  1. added 3 commits that reference this issue on Feb 15, 2026
    81a1db7
    9c7fb83
    1f583de
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions