cube-js/cube · error
Auth isn't set
Error message
Auth isn't set
What it means
LivePreviewWatcher.startWatch requires setAuth to have been called first; if this.auth is null it throws "Auth isn't set". The watcher cannot sync files to Cube Cloud without the deployment identity stored in the auth object.
Source
Thrown at packages/cubejs-backend-cloud/src/live-preview.ts:45
public setAuth(token: string): AuthObject {
try {
const payload = JSON.parse(Buffer.from(token.split('.')[1], 'base64').toString());
this.auth = {
auth: token,
deploymentId: payload.deploymentId,
url: payload.url,
};
return this.auth;
} catch (e: any) {
internalExceptions(e);
throw new Error('Live-preview token is invalid');
}
}
public startWatch(): void {
if (!this.auth) {
throw new Error('Auth isn\'t set');
}
if (!this.watcher) {
this.log('Start with Cube Cloud');
this.watcher = chokidar.watch(
process.cwd(),
{
ignoreInitial: false,
ignored: [
'**/node_modules/**',
'**/.*'
]
}
);
let preSaveTimeout: NodeJS.Timeout;
this.watcher.on('all', (/* event, p */) => {
if (preSaveTimeout) clearTimeout(preSaveTimeout);View on GitHub (pinned to 7d981676b3)
Solutions
- Call setAuth(validLivePreviewJwt) before startWatch().
- Ensure the live-preview token is supplied through your startup flow (env var/config) so the auth step runs before watching begins.
- If setAuth throws, fix the token first — startWatch will keep failing until auth is successfully set.
- Order your boot code: create watcher → setAuth → startWatch.
Example fix
// before const watcher = new LivePreviewWatcher(); watcher.startWatch(); // throws 'Auth isn't set' // after const watcher = new LivePreviewWatcher(); watcher.setAuth(process.env.CUBE_LIVE_PREVIEW_TOKEN!); watcher.startWatch();
Defensive patterns
Strategy: validation
Validate before calling
if (!watcher['auth']) throw new Error('Call setAuth(token) before startWatch()');
// or expose/check via a wrapper that tracks auth state Try / catch
try {
watcher.startWatch();
} catch (e) {
if (e instanceof Error && e.message === "Auth isn't set") {
watcher.setAuth(process.env.CUBE_LIVE_PREVIEW_TOKEN!);
watcher.startWatch();
} else throw e;
} Prevention
- Enforce boot order: construct watcher → setAuth → startWatch.
- Guard startup code to require the live-preview token env var when live preview mode is enabled.
- Handle setAuth failure explicitly so startWatch is never called in an unauthenticated state.
When it happens
Trigger: Calling startWatch() on a freshly constructed LivePreviewWatcher without calling setAuth(token) beforehand, or after setAuth failed earlier and left this.auth unset.
Common situations: Running the dev server in live-preview mode without providing the live-preview token; providing an invalid token (see 'Live-preview token is invalid') so auth never gets set; a code path that starts watching before authentication completes.
Related errors
- Auth isn't set
- Live-preview token is invalid
- Both user/password and auth token are set. Please remove pas
- Unable to decode JWT key
- JWT without kid inside headers
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/249ccd17f5ea93a4.
Report an issue: GitHub.