{"record":{"id":"02bcf3e200906cfe","repo":"different-ai/openwork","slug":"failed-to-update-scim-group-mapping-response-st","errorCode":null,"errorMessage":"Failed to update SCIM group mapping (${response.status}).","messagePattern":"Failed to update SCIM group mapping \\((.+?)\\)\\.","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ee/apps/den-web/app/(den)/dashboard/_components/scim-screen.tsx","lineNumber":261,"sourceCode":"\n    if (!connection) {\n      setError(\"Create the SCIM connector before enabling group synchronization.\");\n      return;\n    }\n\n    const groupMappingMode = connection.groupMappingMode === \"create_teams\"\n      ? \"metadata_only\"\n      : \"create_teams\";\n    setError(null);\n    setUpdatingGroupMapping(true);\n    try {\n      const { response, payload } = await requestJson(\n        \"/v1/scim\",\n        { method: \"PATCH\", body: JSON.stringify({ groupMappingMode }) },\n        12000,\n      );\n      if (!response.ok) {\n        throw getRequestError(payload, response, `Failed to update SCIM group mapping (${response.status}).`);\n      }\n      const parsed = parseOrgScimPayload(payload);\n      if (!parsed.connection) {\n        throw new Error(\"SCIM settings were updated, but the response was incomplete.\");\n      }\n      setConnection(parsed.connection);\n      setHealth(parsed.health);\n    } catch (nextError) {\n      setError(nextError instanceof Error ? nextError.message : \"Failed to update SCIM group mapping.\");\n    } finally {\n      setUpdatingGroupMapping(false);\n    }\n  }\n\n  async function handleDeleteConnection() {\n    if (!access.canManageScim) {\n      setError(\"Only workspace owners and super-admins can delete SCIM connections.\");\n      return;","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-web/app/(den)/dashboard/_components/scim-screen.tsx#L243-L279","documentation":"handleGroupMappingChange in scim-screen.tsx throws this when PATCH /v1/scim with { groupMappingMode } returns non-ok. It updates how SCIM group mappings are applied for the org; the error means the server rejected the change. On success it re-parses the payload and requires a connection object back.","triggerScenarios":"PATCH /v1/scim returns 400 (invalid groupMappingMode value), 401/403 (auth/permission), 404 (no SCIM connection), or 5xx. Also when a stale UI sends a mode value the current server version no longer accepts.","commonSituations":"Selecting a mapping mode from a stale page after a server upgrade renamed modes; non-admin toggling settings; org lost its SCIM connection between load and save.","solutions":["Check status 400 and the payload: send only groupMappingMode values the server accepts (refresh the page to get current options).","For 401/403, re-authenticate or use an org-admin account.","404: re-provision the SCIM connection, then change the mapping.","Retry after transient 5xx."],"exampleFix":"// before: sending raw state that may be outdated\nawait requestJson('/v1/scim', { method: 'PATCH', body: JSON.stringify({ groupMappingMode: mode }) });\n// after: whitelist known modes\nconst validModes = ['filter', 'sync_all'];\nif (!validModes.includes(mode)) throw new Error('Unsupported group mapping mode.');\nawait requestJson('/v1/scim', { method: 'PATCH', body: JSON.stringify({ groupMappingMode: mode }) });","handlingStrategy":"validation","validationCode":"const VALID_MODES = connection?.supportedGroupMappingModes ?? [];\nif (!VALID_MODES.includes(groupMappingMode)) {\n  throw new Error('Unsupported group mapping mode for this connection.');\n}","typeGuard":"function isGroupMappingMode(v: unknown): v is string {\n  return typeof v === 'string' && ['filter', 'sync_all'].includes(v);\n}","tryCatchPattern":"try {\n  await updateGroupMapping(mode);\n} catch (e) {\n  const msg = e instanceof Error ? e.message : String(e);\n  if (/\\(400\\)/.test(msg)) { await loadScimConfig(); toast('That mapping mode is no longer supported — options refreshed.'); }\n  else toast(msg);\n}","preventionTips":["Derive selectable modes from the freshly loaded connection, not hardcoded constants.","Reload SCIM config when the settings tab regains focus to avoid stale mode values.","Restrict PATCH access to org admins in the UI and server policy.","Show inline field errors from the 400 payload."],"tags":["http","api","scim","settings"],"backgroundTag":"http-non-ok-response","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}