{"record":{"id":"4ca9ac8fd65e7367","repo":"halo-dev/halo","slug":"json-detail","errorCode":null,"errorMessage":"json.detail","messagePattern":"json\\.detail","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"application/src/main/resources/templates/gateway_fragments/complete_profile.html","lineNumber":90,"sourceCode":"\n      async function sendRequest() {\n        const email = document.getElementById(\"email\").value;\n        const response = await fetch(\"/complete-profile/send-email-code\", {\n          method: \"POST\",\n          body: JSON.stringify({ email: email }),\n          headers: {\n            \"Content-Type\": \"application/json\",\n            [headerName]: token,\n          },\n        });\n\n        if (!response.ok) {\n          const json = await response.json();\n          if (json.errors && json.errors.length) {\n            throw new Error(json.errors[0]);\n          }\n          if (json.detail) {\n            throw new Error(json.detail);\n          }\n          throw new Error(i18nResources.sendVerificationCodeFailed);\n        }\n\n        return response;\n      }\n\n      const emailCodeSendButton = document.getElementById(\"emailCodeSendButton\");\n      sendVerificationCode(emailCodeSendButton, sendRequest);\n    });\n  </script>\n</form>\n","sourceCodeStart":72,"sourceCodeEnd":103,"githubUrl":"https://github.com/halo-dev/halo/blob/d2f5165f9c8f055ffcb3fa9c3f4032821a7b68c8/application/src/main/resources/templates/gateway_fragments/complete_profile.html#L72-L103","documentation":"Client-side JS in the complete-profile flow: when /complete-profile/send-email-code returns a non-ok response whose body has no errors array but does have a `detail` field (RFC 7807 ProblemDetail shape), sendRequest() throws new Error(json.detail). The Error message is the server-provided detail string. This branch is reached only when json.errors is absent/empty and json.detail is truthy.","triggerScenarios":"The email-code endpoint returns a ProblemDetail response (e.g. 400/409/500) with a `detail` field and no `errors` array — such as a generic server error, a conflict, or a handled exception surfaced as a problem detail.","commonSituations":"Backend throws a mapped exception that serializes to ProblemDetail; rate-limit/throttle response with detail; transient server error.","solutions":["Read the detail string shown to the user; it is the server's explanation.","Retry after addressing the stated reason or once the transient condition clears.","Refresh the page for a new CSRF token if the detail suggests auth/CSRF.","Check server logs if the detail indicates an internal error (5xx)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Validate inputs and freshness before the request (same as 136):\nif (!email || !/^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$/.test(email)) {\n    showError(\"Enter a valid email.\"); return;\n}","typeGuard":"function hasProblemDetail(json) {\n  return json != null && typeof json.detail === \"string\" && json.detail.length > 0;\n}","tryCatchPattern":"try {\n    await sendRequest();\n} catch (e) {\n    // e.message === server's ProblemDetail.detail\n    showToast(e.message || i18nResources.sendVerificationCodeFailed);\n}","preventionTips":["Read the detail string — it is the server's explanation.","Refresh the page for a new CSRF token if the detail suggests auth/CSRF.","Retry after the stated reason is addressed.","Check server logs for 5xx ProblemDetails indicating internal errors."],"tags":["frontend","javascript","email-verification","complete-profile","problem-detail"],"backgroundTag":null,"analyzedSha":"d2f5165f9c8f055ffcb3fa9c3f4032821a7b68c8","analyzedAt":"2026-08-14T00:18:38.915Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}