diegosouzapw/OmniRoute · error · Error
API_KEY_SECRET is required for API key CRC operations. The…
Error message
API_KEY_SECRET is required for API key CRC operations. The startup validator (instrumentation-node.ts) should have set this automatically.
What it means
Fail-fast error from getApiKeySecret(): API_KEY_SECRET is unset or blank when an API-key CRC (checksum) operation is attempted. Since FASE-01 there is no hardcoded fallback; the startup secrets validator (instrumentation-node.ts) is expected to have provisioned it, so hitting this means startup validation was skipped or the env was emptied at runtime.
Solutions
- Generate and set API_KEY_SECRET (e.g. `openssl rand -hex 32`) and restart the server
- Verify .env is loaded and not overwritten by the deployment environment
- Ensure the startup secrets validator ran (check for its boot logs, including the [SECURITY] warning)
- Fix API-key operations being invoked before initialization order completes
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/shared/utils/apiKey.ts:11 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25).
Data as JSON: /api/errors/6a2b1a5f279a7fe7.
Report an issue: GitHub.
Appendix: source
Thrown at src/shared/utils/apiKey.ts:11
import crypto from "crypto";
// FASE-01: No hardcoded fallback — enforced by secretsValidator at startup
if (!process.env.API_KEY_SECRET) {
console.error("[SECURITY] API_KEY_SECRET is not set. API key CRC validation is disabled.");
}
function getApiKeySecret(): string {
const secret = process.env.API_KEY_SECRET;
if (!secret || secret.trim() === "") {
throw new Error(
"API_KEY_SECRET is required for API key CRC operations. " +
"The startup validator (instrumentation-node.ts) should have set this automatically."
);
}
return secret;
}
/**
* Generate 6-char random keyId
*/
function generateKeyId(): string {
const chars = "abcdefghijklmnopqrstuvwxyz0123456789";
let result = "";
result = crypto.randomBytes(3).toString("hex");
return result;
}
/**View on GitHub (pinned to a179ffed5b)