d9-migration-session-tracking — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited d9-migration-session-tracking (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
Detect and fix a silent migration failure in d9 (Directus 9 fork) where migration 20250910A-add-session-tracking registers as completed in directus_migrations but does not actually create the required session_id columns on the directus_sessions and directus_activity tables. This causes a 500 error on login because the auth system tries to write to a column that does not exist.
column "session_id" of relation "directus_sessions" does not exist in d9 server logs after bootstrap.npx directus bootstrap or the d9 Docker entrypoint on a new or migrated database.20250910A-add-session-tracking. SELECT column_name FROM information_schema.columns
WHERE table_name = 'directus_sessions' AND column_name = 'session_id';If zero rows are returned, the migration failed silently.
SELECT * FROM directus_migrations WHERE version = '20250910A';If it exists, d9 will never re-run it.
ALTER TABLE directus_sessions ADD COLUMN IF NOT EXISTS session_id VARCHAR(64);
ALTER TABLE directus_activity ADD COLUMN IF NOT EXISTS session_id VARCHAR(64);pg driver bundled in node_modules (via its full pnpm path) to execute the SQL: PG_PATH=$(find /app/node_modules/.pnpm -path '*/pg/lib/index.js' | head -1)
node -e "
const { Client } = require('${PG_PATH}');
const c = new Client({ connectionString: process.env.DB_CONNECTION_STRING });
(async () => {
await c.connect();
await c.query('ALTER TABLE directus_sessions ADD COLUMN IF NOT EXISTS session_id VARCHAR(64)');
await c.query('ALTER TABLE directus_activity ADD COLUMN IF NOT EXISTS session_id VARCHAR(64)');
await c.end();
console.log('Session tracking columns ensured.');
})().catch(e => { console.error(e); process.exit(1); });
"POST /auth/login with column "session_id" of relation "directus_sessions" does not exist.directus_migrations to force a re-run; this can cause unpredictable behavior if the migration has partial side effects.node_modules/ or the d9 migration directory after bootstrap, as this will not re-trigger already-applied migrations.session_id column type must be VARCHAR(64) to match the d9 auth system expectations.IF NOT EXISTS in all ALTER TABLE statements to make the fix idempotent and safe to run on every container start.node -e inside a pnpm-deployed container, use the full .pnpm/ path for pg (see skill pnpm-deploy-require-path).SELECT column_name FROM information_schema.columns WHERE table_name = 'directus_sessions' AND column_name = 'session_id'; returns exactly one row.SELECT column_name FROM information_schema.columns WHERE table_name = 'directus_activity' AND column_name = 'session_id'; returns exactly one row.POST /auth/login with valid credentials returns HTTP 200 and an access token.Scenario: A new d9 instance is deployed on AWS ECS. The container runs npx directus bootstrap on first start. The bootstrap command completes without errors. An administrator attempts to log in via the d9 admin panel and sees a generic "Unexpected Error" page. The ECS task logs show:
POST /auth/login 500
Error: column "session_id" of relation "directus_sessions" does not existDiagnosis: Connected to RDS via psql. Ran \d directus_sessions and confirmed session_id is absent. Checked directus_migrations and found 20250910A is listed as applied.
Fix applied:
ALTER TABLE directus_sessions ADD COLUMN IF NOT EXISTS session_id VARCHAR(64);
ALTER TABLE directus_activity ADD COLUMN IF NOT EXISTS session_id VARCHAR(64);npx directus start line).Scenario: During initial deployment, the container was killed by an OOM event mid-bootstrap. On restart, npx directus bootstrap sees all migrations (including 20250910A) as already applied. The session_id column exists on directus_sessions but is missing from directus_activity (the migration was interrupted between the two ALTER TABLE statements).
Diagnosis: Login fails with column "session_id" of relation "directus_activity" does not exist. Only directus_activity is affected.
Fix applied:
IF NOT EXISTS skips the column on directus_sessions (already present) and creates it on directus_activity (missing): ALTER TABLE directus_sessions ADD COLUMN IF NOT EXISTS session_id VARCHAR(64);
ALTER TABLE directus_activity ADD COLUMN IF NOT EXISTS session_id VARCHAR(64);Scenario: A developer uses MySQL instead of PostgreSQL and encounters a similar 500 on login with a message about missing session_id.
Diagnosis: Same root cause, but the SQL syntax differs for MySQL.
Fix applied:
MySQL does not support IF NOT EXISTS on ALTER TABLE ADD COLUMN. Use an information_schema check instead:
SET @dbname = DATABASE();
SELECT COUNT(*) INTO @col_exists
FROM information_schema.columns
WHERE table_schema = @dbname AND table_name = 'directus_sessions' AND column_name = 'session_id';
SET @query = IF(@col_exists = 0, 'ALTER TABLE directus_sessions ADD COLUMN session_id VARCHAR(64)', 'SELECT 1');
PREPARE stmt FROM @query;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;Repeat for directus_activity. This edge case highlights that the PostgreSQL-specific IF NOT EXISTS syntax must be adapted when targeting other database engines.
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.