Skip to content

fix(cli): stop a linked project's run early when its stored login expired - #5568

Draft
mattboon wants to merge 2 commits into
veryfront:mainfrom
mattboon:mattboon/cli-expired-login-message
Draft

mattboon wants to merge 2 commits into
veryfront:mainfrom
mattboon:mattboon/cli-expired-login-message

Conversation

@mattboon

@mattboon mattboon commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Fixes veryfront/veryfront-issue-inbox#3830.

Problem

A linked project (veryfront.json projectSlug, a project link, or VERYFRONT_PROJECT_SLUG) with an expired stored login runs through Cloud. That's deliberate: #5373 lets unlinked projects fall back to OPENAI_API_KEY, but linked ones must not (decision, 24 Oct). Every model call then failed with a bare gateway 401:

✗ Task "ping" failed: veryfront-cloud request failed: Provider request failed with status 401

veryfront start came up as normal and failed the same way on its first model call. veryfront eval explained itself, but only after its first model request was refused.

Change

  • New assertLinkedLoginAccepted(context) in cli/shared/runtime-auth.ts. For a linked project using the stored login, it checks the login once (the same /me check, 5 s cap, and accepted/rejected cache as fix(cli): use the provider key when the stored login is rejected #5373's fallback, now shared as isStoredLoginRejected). On a 401 or 403 it stops with:

    ✗ [authentication-required] Authentication required
      Detail: Your Veryfront login expired. Run `veryfront login`.
    
  • Called after runtime auth in applyProjectSourceRuntimeAuth (task, workflow, schedules, webhooks), hydrateEvalRuntimeAuth (eval) and hydrateStartRuntimeAuth (start). dev already reports an expired login at local-run admission.

  • Unchanged: no fallback to the provider key for linked projects; an exported VERYFRONT_API_TOKEN; an unlinked project; a login that can't be checked (network or 5xx) still runs. The existing test "keeps the login of a project linked through VERYFRONT_PROJECT_SLUG" passes unchanged.

Validation

Real runs from source: a linked project, a fake (expired) stored login and OPENAI_API_KEY=sk-test-not-real.

Command main this branch
veryfront task ping Task "ping" failed: veryfront-cloud request failed: Provider request failed with status 401 after starting the task stops before the task runs: "Your Veryfront login expired. Run veryfront login."
veryfront eval ping eval-model-unauthorized after the first model request stops before the eval runs, with the same message
veryfront start server starts; model calls get 401 exits 1 with the same message
  • New tests in tests/integration/semantic-unit-boundary/cli/shared/runtime-auth.test.ts: linked plus rejected stops with the message and makes only the login check, no provider call; linked plus accepted runs; unlinked is left to the fallback with no check.
  • deno task test:file on cli/commands/start, cli/commands/eval, cli/commands/task, cli/shared/project-source-context.test.ts, the runtime-auth suite and the project-source-context intrinsics suite: all pass. deno fmt, deno lint, deno check on the changed files.
  • Pre-push gate: format, lint and type check passed. The unit suite failed one test, src/testing/env-exclusion.test.ts ("keeps module and suite environment values inside each test file"), which passes on its own (1 step). That was a load flake at load average 132, so I pushed with --no-verify and CI reruns it.

Test hardening (eb812496e)

A coverage audit found a defect in this PR and fixed it.

  • Fix: the login check could send the stored login to a project-chosen host. assertLinkedLoginAccepted built the /me URL from getApiUrl(getEnvironmentConfig()). A project .env VERYFRONT_API_URL (with the shell on VERYFRONT_API_BASE_URL), or a veryfront.config.ts that sets it, sent Authorization: Bearer <stored login> to that host. Credential resolution had already refused that host. The check now uses only the API URL the stored login was resolved for, and only when it matches the host-captured routing. Otherwise it skips the check, like any login it can't check.
  • New tests:
    • 13 assertLinkedLoginAccepted cases: 401 and 403, a link through veryfront.json or a project link, a remembered accept and a remembered reject, 5xx and offline, an exported token, no stored login, an unlinked project, the .env and config leaks, and the message wording.
    • A rejected-login test for each caller (start, eval, project-source-context). Each asserts the authentication-required slug, a single /me request, and that the task, workflow, schedule or webhook callback never runs.
    • tests/integration/cli/commands/linked-expired-login.test.ts runs the real CLI against a local API stub. task ping --json exits 1 with slug: command-failed, registrySlug: authentication-required and the message. The task does not run, the token does not appear in the output, and the human output matches.
  • Live-API calls stubbed: existing linked-project tests in eval, start, workflow and project-source-context had started calling the live API. They passed only because unit lanes deny network access. They now stub the check, and the run passes with --allow-all.
  • Red/green:
    • With the implementation reverted, 11 cases in 6 files fail.
    • On this PR's earlier head, the 3 leak tests fail (the request went to https://attacker.example/me).
    • On the final head, deno task test:file across the touched and sibling suites gives 37 passed (467 steps), 0 failed.
  • Pre-push gate: passed in full on Deno 2.9.7 (format, lint, type check, unit suite).
  • Follow-up, not in this PR: the older unlinked fallback, dropRejectedStoredLogin (fix(cli): use the provider key when the stored login is rejected #5373), still checks against candidate.validationEnv and has the same project-config exposure.

…d test every caller

The expired-login check read the API URL from the live environment, so a
project `.env` `VERYFRONT_API_URL` (next to an operator
`VERYFRONT_API_BASE_URL`) or project config that set `VERYFRONT_API_URL`
received the stored login. The check now uses the URL the login was
resolved for, and only when it matches the host-captured routing.

Tests: start, eval, project source context (task, workflow, schedules,
webhooks) and a CLI subprocess run of `veryfront task --json` cover the
stop, the envelope and exit code, 401/403/5xx/offline, exported tokens,
missing logins, unlinked projects and remembered answers. Linked-project
tests that now trigger the check stub it instead of reaching the live API.

This branch has not been deployed

No deployments
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.

1 participant