{"record":{"id":"c540fbcab3478889","repo":"sahat/hackathon-starter","slug":"http-error-status-response-status","errorCode":null,"errorMessage":"HTTP error! status: ${response.status}","messagePattern":"HTTP error! status: (.+?)","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"config/passport.js","lineNumber":605,"sourceCode":"      state: true,\n      passReqToCallback: true,\n    },\n    async (req, token, tokenSecret, profile, done) => {\n      try {\n        if (!token || !tokenSecret) {\n          throw new Error('Missing or invalid token/tokenSecret');\n        }\n        // Helper function to generate the OAuth 1.0a authHeader for Tumblr API.\n        // This function is not going to make any actual calls to\n        // tumblr's /request_token or /access_token endpoints.\n        function getTumblrAuthHeader(url, method) {\n          const oauth = new OAuth('https://www.tumblr.com/oauth/request_token', 'https://www.tumblr.com/oauth/access_token', process.env.TUMBLR_KEY, process.env.TUMBLR_SECRET, '1.0A', null, 'HMAC-SHA1');\n          return oauth.authHeader(url, token, tokenSecret, method);\n        }\n        const userInfoURL = 'https://api.tumblr.com/v2/user/info';\n        const response = await fetch(userInfoURL, { headers: { Authorization: getTumblrAuthHeader(userInfoURL, 'GET') } });\n        if (!response.ok) {\n          throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        const data = await response.json();\n        // Extract user info from the API response\n        const tumblrUser = data.response.user;\n        const primaryBlog = tumblrUser.blogs?.find((blog) => blog.primary) || tumblrUser.blogs?.[0];\n        const providerProfile = {\n          id: primaryBlog.uuid || tumblrUser.name,\n          name: tumblrUser.name,\n          picture: primaryBlog?.avatar?.[0]?.url,\n          website: primaryBlog?.url,\n        };\n        try {\n          const sessionAlreadyLoggedIn = !!req.user;\n          const user = await handleAuthLogin(req, token, null, 'tumblr', {}, providerProfile, sessionAlreadyLoggedIn, tokenSecret, false);\n          if (sessionAlreadyLoggedIn && req.user.id === user.id) {\n            req.flash('info', { msg: 'Tumblr account has been linked.' });\n          }\n          return done(null, user);","sourceCodeStart":587,"sourceCodeEnd":623,"githubUrl":"https://github.com/sahat/hackathon-starter/blob/c12e339564db59443df0b901818c9bb661331b28/config/passport.js#L587-L623","documentation":"After a successful Tumblr OAuth 1.0a login, the strategy fetches https://api.tumblr.com/v2/user/info with a signed header and throws on any non-2xx HTTP status.","triggerScenarios":"Tumblr's user/info endpoint returns 401 (bad signature/expired token), 429 (rate limit), or 5xx during the verify callback of the Tumblr strategy.","commonSituations":"System clock skew breaking the HMAC-SHA1 signed header, revoked or expired access token, TUMBLR_KEY changed since the token was issued, or Tumblr API downtime/rate limiting.","solutions":["Check response.status in server logs: 401 → re-authorize the app (unlink/relink); 429 → back off and retry","Verify system clock is accurate (OAuth 1.0a timestamps are sensitive)","Confirm TUMBLR_KEY/TUMBLR_SECRET in .env still match the registered Tumblr app"],"exampleFix":"// before\nif (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);\n// after\nif (!response.ok) return done(null, false, { msg: `Tumblr API returned ${response.status}. Try relinking your account.` });","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (e) { if (/HTTP error! status: (401|429)/.test(e.message)) { /* re-auth or backoff */ } throw e; }","preventionTips":["Keep server clocks NTP-synced for OAuth 1.0a signing","Handle non-OK as done(null,false) with a flash message instead of a hard throw"],"tags":["oauth","tumblr","http-status","fetch"],"backgroundTag":"upstream-api-http-error","analyzedSha":"c12e339564db59443df0b901818c9bb661331b28","analyzedAt":"2026-08-27T11:05:00.872Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}