{"record":{"id":"fe5fc4aec08cbc80","repo":"paperclipai/paperclip","slug":"a-valid-browser-code-is-required","errorCode":null,"errorMessage":"A valid browser code is required.","messagePattern":"A valid browser code is required\\.","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"server/src/routes/agents.ts","lineNumber":5342,"sourceCode":"  ): Promise<void> => {\n    const id = req.params.id as string;\n    const agent = await getAccessibleResource(req, res, svc.getById(id), \"Agent not found\");\n    if (!agent) return;\n\n    if (req.actor.type === \"agent\") {\n      if (req.actor.agentId !== id) {\n        res.status(403).json({ error: \"Agent can only invoke itself\" });\n        return;\n      }\n    } else {\n      await assertBoardCanManageAgentsForCompany(req, agent.companyId);\n    }\n    if (req.body.debug?.providerTrace === \"raw\") {\n      assertInstanceAdmin(req);\n    }\n    if (agent.orgChainHealth?.status === \"invalid_org_chain\") {\n      res.status(409).json({\n        error: agent.orgChainHealth?.repairGuidance ?? \"Repair this agent's reporting chain before starting runs\",\n      });\n      return;\n    }\n\n    const run = await heartbeat.wakeup(id, {\n      source: opts.source,\n      triggerDetail: req.body.triggerDetail ?? \"manual\",\n      reason: req.body.reason ?? null,\n      payload: req.actor.type === \"agent\" && req.body.payload\n        ? { ...req.body.payload, commentId: undefined, wakeCommentId: undefined, wakeCommentIds: undefined }\n        : req.body.payload ?? null,\n      idempotencyKey: req.body.idempotencyKey ?? null,\n      requestedByActorType: req.actor.type === \"agent\" ? \"agent\" : \"user\",\n      requestedByActorId: req.actor.type === \"agent\" ? req.actor.agentId ?? null : req.actor.userId ?? null,\n      contextSnapshot: {\n        triggeredBy: req.actor.type,\n        originIdentityContextId: req.actor.identityContextId ?? null,\n        responsibleUserId: req.actor.type === \"agent\" ? req.actor.onBehalfOfUserId ?? null : req.actor.userId ?? null,","sourceCodeStart":5324,"sourceCodeEnd":5360,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/server/src/routes/agents.ts#L5324-L5360","documentation":"Body guard on the setup-token login code exchange: exchanging the browser code requires a non-empty valid code in the request body, but it is missing or malformed, so the OAuth-style exchange is refused with 400 before any code is redeemed.","triggerScenarios":"Thrown at server/src/routes/agents.ts:4769 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide the valid browser code from the login flow and retry."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}