Repository navigation
fix(#70): job token uses the job's timeout; keep own enterprise token - #135
fullsend-ai-coder[bot] wants to merge 2 commits into
Conversation
job_token_lifetime reads timeout_minutes from the job, but WorkflowJob had no such column and the parsed timeout-minutes was never stored, so every upstream-runner job token lived 360 + 5 minutes: longer than a short job may run, and expiring before a job over 360 minutes ends. - Add nullable workflow_jobs.timeout_minutes (migration 0022 on head 0021); NULL means the 360-minute default. - Store the parsed timeout-minutes at job creation when it is a positive number; an unevaluated expression gets the default. Dynamic matrix instances copy it in workflow_scheduler. - _with_gh_enterprise_token mirrors GH_TOKEN/GITHUB_TOKEN into the enterprise variables only when the step sets neither of them. gh reads GH_ENTERPRISE_TOKEN first, so mirroring it beside a workflow's own GITHUB_ENTERPRISE_TOKEN overrode that choice. Tests cover the stored value, job_token_lifetime and the issued token's exp - iat with and without timeout-minutes, matrix instances, the enterprise-token case, and the migration on an existing database. pre-commit could not fetch its hook repos in the sandbox; the pre-commit-hooks checks and ruff 0.17.3 were run directly and passed. Full suite: 1564 passed; test_runner_shutdown and test_security_headers (frontend dist not built) fail identically on main. Closes #70 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🤖 Finished Review · ✅ Success · Started 2:50 PM UTC · Completed 2:58 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $1.41 |
|
Risk Assessment: moderate (2/5) DetailsModerate risk driven by a schema migration and recent churn in workflow service files, balanced by moderate diff size, strong test coverage, and exact alignment with linked issue #70. |
ReviewHead SHA: bb9d107 PR #135 stores Findings
Risk assessment: moderate (2/5). It includes a schema migration, with strong test coverage and a close match to the linked issue. Labels: PR is a bug fix for the job token timeout. Next steps:
|
|
🤖 Finished Fix · ✅ Success · Started 3:00 PM UTC · Completed 3:04 PM UTC Commit: Runtime: claude · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $0.32 |
_timeout_minutes now returns None for non-finite floats, non-ASCII digit strings and strings too long to convert, and caps the value at 24 hours (the job token lifetime cap) so it always fits the Integer column. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
🔧 Fix agent — iteration 1 (bot-triggered)Made timeout-minutes normalization total (non-finite floats, Unicode digit strings, oversized values) and added tests. Fixed (1):
Tests: passed CI inspections (2):
Conflict update: skipped; strategy Finding threads:
Next steps:
Updated by fullsend fix agent |
|
🤖 Finished Review · ✅ Success · Started 3:07 PM UTC · Completed 3:13 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $1.00 |
|
Risk Assessment: moderate (2/5) DetailsModerate risk driven by an Alembic schema migration and recent churn in workflow service files, balanced by moderate change size, bot authorship, solid test coverage, and complete alignment with linked issue #70. |
|
Looks good to me Earlier findings
|
Superseded by updated review
Summary
The upstream runner's job token is supposed to live for the job's
timeout-minutesplus 5 minutes, capped at 24 hours.job_token_lifetimereadsjob.timeout_minutes, butWorkflowJobhad no such column, and thetimeout-minutesvalue parsed inworkflow_servicewas never stored. So every token lived 365 minutes. That is too long for atimeout-minutes: 30job. For a job longer than 360 minutes, the token expired before the job ended, and from plan version 8 the job's completion report then got 401.Separately,
_with_gh_enterprise_tokenfilled each enterprise variable on its own. A step that set onlyGITHUB_ENTERPRISE_TOKENstill gotGH_ENTERPRISE_TOKENcopied fromGH_TOKEN.ghreadsGH_ENTERPRISE_TOKENfirst, so it used the copied token instead of the one the workflow chose.Changes
src/app/models/actions.py: new nullableWorkflowJob.timeout_minutes. NULL means the 360-minute default.alembic/versions/0022_workflow_job_timeout_minutes.py: adds the column on top of the current head,0021_runner_registration_broker. It follows the idempotent add-column pattern of 0020/0021.src/app/services/workflow_service.py:build_job_graphturnstimeout-minutesinto a positive integer orNone, via_timeout_minutes. Job creation stores it. An expression like${{ inputs.timeout }}is not evaluated here, so it gets the default.src/app/services/workflow_scheduler.py: dynamic-matrix instances copytimeout_minutesfrom the job they are expanded from. Static matrix jobs already go through the creation path above.src/app/api/actions_distributed_task.py: the token is copied into the enterprise variables only when the step's environment sets neither of them. A step that sets one of them gets nothing copied, and other steps still get the token copied as before.docs/bugs/fixed/job-token-ignores-the-jobs-timeout-minutes.md: work-ledger record.Testing
tests/actions/test_runner_job_outputs.py: jobs created from workflow YAML withtimeout-minutes: 30and with none. The test checks the stored value (30 / NULL),job_token_lifetime, and the claimed token'sexp - iat(35 min / 365 min).tests/actions/test_dynamic_matrix.py: every dynamic-matrix instance keepstimeout_minutes.tests/actions/test_runner_gh_host.py: a step withGH_TOKENandGITHUB_ENTERPRISE_TOKENkeeps its own value, and noGH_ENTERPRISE_TOKENis added.tests/test_database_migrations.py: 0022 adds the column to a database at 0021, and existing jobs get NULL.test_runner_shutdown::test_a_shutdown_signal_fails_the_running_step_and_stops_its_processesandtest_security_headers::test_admin_ui_and_unreserved_admin_path_include_security_headers(the frontenddistis not built in the sandbox). Both fail the same way on unmodifiedmain.ruff check(0.17.3) passes on every file changed here. I also fixed one import-order finding that was already intests/actions/test_dynamic_matrix.py, because a touched file must pass ruff.pre-commitcould not fetch its hook repositories in the sandbox. Thepre-commit-hooksv6.0.0 checks, ruff and the secret scan were run directly and passed. shellcheck, actionlint, zizmor and the frontend hooks don't match any changed file.🤖 Generated with Claude Code
Closes #70
Post-script verification
agent/70-job-token-timeout-minutes)0454bace16539f60483343fc2079d8b7d7a6ebc7..HEAD)