Skip to content

fix: add missing expires_at in global_tokens_test INSERT statements#609

Open
sap-yuan wants to merge 5 commits into
masterfrom
fix/global-token-test-expires-at
Open

fix: add missing expires_at in global_tokens_test INSERT statements#609
sap-yuan wants to merge 5 commits into
masterfrom
fix/global-token-test-expires-at

Conversation

@sap-yuan
Copy link
Copy Markdown
Collaborator

Problem

The CI gate test test/api fails with 14 errors. The root cause is:

psycopg2.errors.NotNullViolation: null value in column "expires_at" violates not-null constraint

The global_token table (created in migration 00045.sql) defines expires_at TIMESTAMP NOT NULL, but the test file global_tokens_test.py has three direct INSERT statements that omit this column.

The first failing test (test_access_log_enforces_ownership) triggers the NOT NULL violation, which puts the PostgreSQL transaction into a failed state. All subsequent tests then fail with InFailedSqlTransaction because the setUp() TRUNCATE cannot execute.

Fix

Add expires_at = NOW() + INTERVAL '30 days' to all three direct INSERT statements in the test file:

  • test_list_tokens_only_returns_own_tokens (line 44)
  • test_cannot_delete_other_users_token (line 122)
  • test_access_log_enforces_ownership (line 183)

Yuan Huang added 5 commits May 25, 2026 14:30
The global_token table (migration 00045) defines expires_at as NOT NULL,
but the test was inserting rows without providing this column, causing
NotNullViolation errors that cascaded into all 14 test failures.

Add expires_at = NOW() + INTERVAL '30 days' to the three direct INSERT
statements in global_tokens_test.py.
The package.json engines field requires node>=20.0.0 and npm>=10.0.0,
but the CI Dockerfile was still using node:8.9-alpine. The build.js
version check rejects the old runtime, causing the build to fail.
The cp -r of ~50,000 small files in node_modules was causing the CI job
to timeout (1 hour). Using tar pipe for sequential bulk I/O reduces the
copy time from minutes to seconds.
The real bottleneck was not cp -r in build.sh but job.py's post-build
step that compresses and uploads /infrabox/cache via snappy+tar to the
API server. With node:20's much larger node_modules (~200MB+), this
compression/upload exceeds the 1-hour job timeout.

Solution: stop writing node_modules back to /infrabox/cache. Instead,
use mv to restore cached node_modules at the start (fast), and don't
write it back (npm install with warm cache only takes ~20s anyway).
This eliminates the expensive cache upload entirely.
…hang

webpack 3.12.0 leaves open handles (internal timers/fs watchers) under
Node.js 20, causing the process to never exit naturally after a
successful build. The container hangs, docker run waits forever, and
the InfraBox job hits the 1-hour timeout.

The failure path already calls process.exit(1) explicitly; mirror that
for the success path with process.exit(0).

Root cause introduced by 34ade8f (node:8.9 -> node:20-alpine upgrade).
@sap-yuan sap-yuan self-assigned this May 29, 2026
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