{"record":{"id":"5ea2c480c01cb3be","repo":"paperclipai/paperclip","slug":"setup-token-login-session-not-found-5ea2c4","errorCode":null,"errorMessage":"Setup-token login session not found.","messagePattern":"Setup-token login session not found\\.","errorType":"exception","errorClass":"SetupTokenSessionError","httpStatus":404,"severity":"error","filePath":"server/src/services/setup-token-session.ts","lineNumber":1059,"sourceCode":"        // The writer transitions the durable row to `stored` and writes the\n        // secret in one transaction. A zero-row transition or a storage failure\n        // rejects and rolls back both.\n        await this.completeCredential({ scope: session.scope, sessionId: session.id, token });\n      } catch {\n        await this.terminateLocked(session, \"failed\");\n        throw new SetupTokenSessionError(500, SETUP_TOKEN_STORAGE_FAILED);\n      }\n      // The transaction committed while the service held the lock, so a cancel or\n      // an expiry could not interleave. Record the non-secret marker. The durable\n      // row is already `stored` from the committed transition.\n      session.secretStored = true;\n    });\n  }\n\n  /**\n   * Resolves a session for an operation. It returns the session only when the\n   * id exists and the stored scope equals the caller scope in all three identity\n   * fields: the company, the owner, and the adapter. A missing session and a\n   * cross-scope session both throw the same not-found error, so a caller cannot\n   * tell them apart. The scope match makes a cross-company, a cross-owner, and a\n   * cross-adapter session return the same not-found error as a missing session.\n   */\n  private resolveOwned(sessionId: string, scope: SetupTokenSessionScope): StoredSession {\n    const session = this.sessions.get(sessionId);\n    if (\n      !session ||\n      session.scope.companyId !== scope.companyId ||\n      session.scope.ownerUserId !== scope.ownerUserId ||\n      session.scope.adapterType !== scope.adapterType\n    ) {\n      throw new SetupTokenSessionError(404, SETUP_TOKEN_SESSION_NOT_FOUND);\n    }\n    return session;\n  }\n\n  /**","sourceCodeStart":1041,"sourceCodeEnd":1077,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/server/src/services/setup-token-session.ts#L1041-L1077","documentation":"SetupTokenSessionService.resolveOwned found no stored session whose id matches AND whose scope (company, owner, adapter) equals the caller scope. Missing and cross-scope sessions intentionally raise the same not-found error so callers cannot probe other scopes.","triggerScenarios":"Thrown at server/src/services/setup-token-session.ts:1022 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Restart the setup-token login flow to create a fresh session","Verify the session id was copied complete and unmodified","Confirm the session belongs to the same company, owner user, and adapter as the caller","Check the session was not expired/evicted by retention cleanup"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-08-21T17:58:32.592Z","contentChangedAt":"2026-08-21T17:58:32.592Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}