{"record":{"id":"df6eefac70476dde","repo":"juspay/hyperswitch","slug":"no-user-info-token-available","errorCode":null,"errorMessage":"No user info token available","messagePattern":"No user info token available","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cypress-tests/cypress/support/commands.js","lineNumber":6928,"sourceCode":"          }\n          globalState.set(\"userInfoToken\", userInfoToken);\n        }\n      } else {\n        throw new Error(\n          `2FA terminate call failed with status: \"${response.status}\" and message: \"${response.body.error.message}\"`\n        );\n      }\n    });\n  });\n});\nCypress.Commands.add(\"userInfo\", (globalState) => {\n  // Define the necessary variables and constant\n  const baseUrl = globalState.get(\"baseUrl\");\n  const userInfoToken = globalState.get(\"userInfoToken\");\n  const url = `${baseUrl}/user`;\n\n  if (!userInfoToken) {\n    throw new Error(\"No user info token available\");\n  }\n\n  cy.request({\n    method: \"GET\",\n    url: url,\n    headers: {\n      Authorization: `Bearer ${userInfoToken}`,\n      \"Content-Type\": \"application/json\",\n    },\n    failOnStatusCode: false,\n  }).then((response) => {\n    logRequestId(response.headers[\"x-request-id\"]);\n\n    cy.wrap(response).then(() => {\n      if (response.status === 200) {\n        expect(response.body, \"merchant_id\").to.have.property(\"merchant_id\").and\n          .to.not.be.empty;\n        expect(response.body, \"organization_id\").to.have.property(\"org_id\").and","sourceCodeStart":6910,"sourceCodeEnd":6946,"githubUrl":"https://github.com/juspay/hyperswitch/blob/9b8b89dc378b62c9a6feda647bad4719d2de7699/cypress-tests/cypress/support/commands.js#L6910-L6946","documentation":"Thrown synchronously by the userInfo command when globalState has no 'userInfoToken'. This token is only set by a successful terminate2Fa (token_type 'user_info'), so the error means the login sequence was broken or skipped before userInfo ran.","triggerScenarios":"Calling cy.userInfo(globalState) without cy.userLogin + cy.terminate2Fa having completed; terminate2Fa returned 200 but with a different token_type so nothing was stored; state reset between specs.","commonSituations":"Copy-pasting only the userInfo step into a new spec; an earlier login step failing silently (e.g., token_type mismatch branch stores nothing); globalState cleared by a beforeEach/afterEach.","solutions":["Run the full chain in the before hook: cy.userLogin(globalState); cy.terminate2Fa(globalState); cy.userInfo(globalState);","If login already ran, verify terminate2Fa's response token_type was 'user_info' — any other value leaves userInfoToken unset without erroring","Ensure no state-reset hook wipes userInfoToken between setup and use"],"exampleFix":"// before\ncy.userInfo(globalState); // userInfoToken never set\n// after\nif (!globalState.get('userInfoToken')) {\n  cy.userLogin(globalState);\n  cy.terminate2Fa(globalState);\n}\ncy.userInfo(globalState);","handlingStrategy":"validation","validationCode":"// run the full login chain only when the token is absent\nif (!globalState.get('userInfoToken')) {\n  cy.userLogin(globalState);\n  cy.terminate2Fa(globalState);\n}\ncy.userInfo(globalState);","typeGuard":"const hasUserInfoTokenInState = (globalState) =>\n  typeof globalState.get('userInfoToken') === 'string' &&\n  globalState.get('userInfoToken').length > 0;","tryCatchPattern":null,"preventionTips":["Encapsulate the login chain in one custom command (e.g. cy.loginUser(globalState)) so specs cannot skip steps","Never clear globalState between setup and the userInfo call","Treat 'No user info token available' as a sequencing smell, not a server problem"],"tags":["cypress","auth","sequence","global-state","precondition"],"backgroundTag":null,"analyzedSha":"9b8b89dc378b62c9a6feda647bad4719d2de7699","analyzedAt":"2026-08-16T09:01:53.433Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}