You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
OIDC token expires during flake evaluation, causing 401 on publish #275
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).
Activity
fix: defer OIDC token acquisition until after Nix evaluation
ci(github-actions/builder): build flakehub-push from fork for OIDC fix
ci(github-actions/builder): build flakehub-push from fork for OIDC fix