cube-js/cube · warning

Unable to resolve file "${value}" from ${key}

Error message

Unable to resolve file "${value}" from ${key}

What it means

Cube reads certain env vars (e.g. CUBEJS_DB_KEY_PATH, SSL cert vars) as paths to files whose contents should be inlined. When the env var is listed as a file-resolvable key, looks like a path, but no file exists at that path, Cube logs this warning, clears the value, and continues with an empty string instead of the file content.

Source

Thrown at packages/cubejs-backend-cloud/src/config.ts:64

      const env = dotenv.config({ path: envFile, multiline: 'line-breaks' }).parsed;
      if (env) {
        if ('CUBEJS_DEV_MODE' in env) {
          delete env.CUBEJS_DEV_MODE;
        }

        const resolvePossibleFiles = [
          'CUBEJS_DB_SSL_CA',
          'CUBEJS_DB_SSL_CERT',
          'CUBEJS_DB_SSL_KEY',
        ];

        // eslint-disable-next-line no-restricted-syntax
        for (const [key, value] of Object.entries(env)) {
          if (resolvePossibleFiles.includes(key) && isFilePath(value)) {
            if (fs.existsSync(value)) {
              env[key] = fs.readFileSync(value, 'ascii');
            } else {
              console.warn(`Unable to resolve file "${value}" from ${key}`);

              env[key] = '';
            }
          }
        }

        return env;
      }
    }

    return {};
  }

  public async addAuthToken(authToken: string, config?: Configuration): Promise<ConfigurationFull> {
    if (!config) {
      config = await this.loadConfig();
    }

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Create/mount the file at the exact path given in the env var and restart Cube
  2. Use an absolute path in the env var to avoid relative-path resolution issues
  3. If the value is actual inline content, move it out of the file-resolvable env var keys (or change the key so it is not treated as a path)
  4. Verify the volume/secret is mounted in the container before the Cube process starts

Example fix

// before
CUBEJS_DB_KEY=/secrets/db.key   (file not mounted)
// after
CUBEJS_DB_KEY=/etc/cube/secrets/db.key   (mount: k8s secret at /etc/cube/secrets/)
Defensive patterns

Strategy: validation

Validate before calling

const p = process.env.CUBEJS_DB_KEY;
if (p && !fs.existsSync(p)) {
  throw new Error(`File for CUBEJS_DB_KEY does not exist: ${p}`);
}

Type guard

function isFilePath(v: unknown): v is string {
  return typeof v === 'string' && (v.startsWith('/') || v.startsWith('./'));
}

Prevention

When it happens

Trigger: An env var such as CUBEJS_DB_KEY or CUBEJS_DB_CERT is set to a file path; fs.existsSync(path) returns false at startup, so the warn branch in envFile fires.

Common situations: Container images where the secret/cert file was not mounted or was mounted at a different path; typos in the path; working directory differences making relative paths invalid; Kubernetes secrets not mounted before Cube starts.

Related errors


AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02). Data as JSON: /api/errors/36eb7ba1d9f2bdb8. Report an issue: GitHub.