{"record":{"id":"4bde0436d616bcc1","repo":"dotnet/orleans","slug":"api-load-failed-with-response-status","errorCode":null,"errorMessage":"/api/load failed with ${response.status}","messagePattern":"/api/load failed with (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"playground/DurableJobsJournaling/DurableJobsJournaling.Web/wwwroot/index.html","lineNumber":117,"sourceCode":"        options.body = JSON.stringify(body);\n      }\n\n      const response = await fetch(url, options);\n      if (!response.ok) {\n        throw new Error(`${url} failed with ${response.status}`);\n      }\n\n      await refresh();\n    }\n\n    async function saveSettings() {\n      const response = await fetch('/api/load', {\n        method: 'PUT',\n        headers: { 'content-type': 'application/json' },\n        body: JSON.stringify(settings())\n      });\n      if (!response.ok) {\n        throw new Error(`/api/load failed with ${response.status}`);\n      }\n\n      applySettings(await response.json());\n      await refresh();\n    }\n\n    async function startLoad() {\n      await post('/api/load/start', settings());\n    }\n\n    function settings() {\n      return {\n        targetConcurrency: Number(concurrency.value),\n        targetStartsPerSecond: Number(throughput.value),\n        stageDelayMilliseconds: 0,\n        stageJitterMilliseconds: 0,\n        failureRate: 0,\n        dueTimeMode: 'Immediate',","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/playground/DurableJobsJournaling/DurableJobsJournaling.Web/wwwroot/index.html#L99-L135","documentation":"A browser-side Error thrown by saveSettings() in the DurableJobsJournaling web frontend when the PUT /api/load request to save load-test settings returns a non-2xx status. Unlike the generic post() helper, this path issues a PUT with a JSON body and checks response.ok before applying the returned settings and refreshing. The message is hardcoded to '/api/load'.","triggerScenarios":"The user changes settings in the UI and the action triggers saveSettings(); the server rejects the PUT — e.g., the settings JSON fails server validation, the load controller is missing, or the backend is down.","commonSituations":"Invalid settings values (out-of-range rates, negative counts), a controller/model-validation failure on the server, or backend unavailability. The error status in the message distinguishes them.","solutions":["Read the status code in the message: 400 => invalid settings payload, 404 => route missing, 5xx => server fault.","Validate the settings object client-side (ranges, required fields) before sending the PUT.","Check server logs for model-validation or controller exceptions on /api/load."],"exampleFix":"// before\nif (!response.ok) {\n  throw new Error(`/api/load failed with ${response.status}`);\n}\n\n// after (capture server validation detail)\nif (!response.ok) {\n  const detail = await response.text().catch(() => \"<no body>\");\n  throw new Error(`/api/load failed with ${response.status}: ${detail}`);\n}","handlingStrategy":"validation","validationCode":"function validateSettings(s) {\n  if (typeof s.rate !== 'number' || s.rate < 0) throw new Error('rate must be >= 0');\n  // ...other fields\n  return s;\n}\n// call before fetch('/api/load', ...)","typeGuard":"function isSettings(o) {\n  return o && typeof o === 'object'\n    && typeof o.rate === 'number' && o.rate >= 0;\n}","tryCatchPattern":"async function saveSettings() {\n  try {\n    const response = await fetch('/api/load', { method:'PUT', headers:{'content-type':'application/json'}, body: JSON.stringify(settings()) });\n    if (!response.ok) throw new Error(`/api/load failed: ${response.status}`);\n    applySettings(await response.json());\n    await refresh();\n  } catch (err) {\n    showError('Settings not saved: ' + err.message);\n  }\n}","preventionTips":["Validate settings client-side (ranges, required fields) before the PUT.","Show save errors in the UI rather than only logging.","Confirm the backend route and model binding accept your payload shape."],"tags":["javascript","fetch","frontend","http","validation"],"backgroundTag":null,"analyzedSha":"fca799fa70ecb6ad975224271703ca43221f58de","analyzedAt":"2026-08-13T19:55:57.938Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}