{"record":{"id":"3d6ee84ff6f8e71f","repo":"bitwarden/server","slug":"organization-connection-configuration-malformed","errorCode":null,"errorMessage":"Organization Connection configuration malformed","messagePattern":"Organization Connection configuration malformed","errorType":"exception","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"src/Api/AdminConsole/Models/Request/Organizations/OrganizationConnectionRequestModel.cs","lineNumber":41,"sourceCode":"\npublic class OrganizationConnectionRequestModel<T> : OrganizationConnectionRequestModel where T : IConnectionConfig\n{\n    public T ParsedConfig { get; private set; }\n\n    public OrganizationConnectionRequestModel(OrganizationConnectionRequestModel model)\n    {\n        Type = model.Type;\n        OrganizationId = model.OrganizationId;\n        Enabled = model.Enabled;\n        Config = model.Config;\n\n        try\n        {\n            ParsedConfig = model.Config.Deserialize<T>(JsonHelpers.IgnoreCase);\n        }\n        catch (JsonException)\n        {\n            throw new BadRequestException(\"Organization Connection configuration malformed\");\n        }\n    }\n\n    public OrganizationConnectionData<T> ToData(Guid? id = null) =>\n        new()\n        {\n            Id = id,\n            Type = Type,\n            OrganizationId = OrganizationId,\n            Enabled = Enabled,\n            Config = ParsedConfig,\n        };\n}\n","sourceCodeStart":23,"sourceCodeEnd":55,"githubUrl":"https://github.com/bitwarden/server/blob/e93b962371d80964556f5590c6615f5160a437a1/src/Api/AdminConsole/Models/Request/Organizations/OrganizationConnectionRequestModel.cs#L23-L55","documentation":"Thrown as a 400 BadRequestException(\"Organization Connection configuration malformed\") from the OrganizationConnectionRequestModel constructor when model.Config.Deserialize<T>(JsonHelpers.IgnoreCase) raises a JsonException. The Config string must be valid JSON deserializable to the strongly-typed config T for the connection Type (e.g., Scim or Sync). A malformed payload aborts construction before the request reaches the controller body.","triggerScenarios":"POST/PUT an organization connection (e.g., SCIM or Directory Sync) where model.Config is not valid JSON, or is valid JSON whose shape does not match the expected config type T for the given connection Type. Missing required properties, wrong types, or stray trailing characters all produce a JsonException.","commonSituations":"Client serialized the config with the wrong property names/casing that the ignore-case deserializer still cannot map; Config sent as a non-JSON string; schema version mismatch (client built for an older/newer config type than the server expects); a trailing comma or unescaped quote in a hand-built JSON string.","solutions":["Validate model.Config parses to the expected type T on the client before sending (serialize a typed object rather than hand-writing JSON).","Match the config schema to the connection Type: use the SCIM config shape for Type=Scim and the Sync shape for Type=Sync.","Run the JSON through a parser/linter to catch syntax errors (trailing commas, unescaped quotes) before submission.","Update the client to the server's current connection-config schema version."],"exampleFix":"// before\nbody.config = '{ \"clientSecret\": ' + secret + ' }'; // unquoted/broken JSON\n// after\nbody.config = JSON.stringify({ clientSecret: secret, tenantId: tenantId });","handlingStrategy":"validation","validationCode":"function configParsesForType(configJson, connectionType) {\n  try {\n    const obj = JSON.parse(configJson);\n    return connectionType === 'scim' ? !!obj.clientSecret : !!obj;\n  } catch { return false; }\n}","typeGuard":"function isOrgConnectionModel(v): v is { type: string; config: string; enabled: boolean; organizationId: string } {\n  return !!v && typeof v.type === 'string' && typeof v.config === 'string';\n}","tryCatchPattern":null,"preventionTips":["Build Config by serializing a typed object (JSON.stringify), never by string concatenation.","Match the Config schema to the connection Type (Scim vs Sync).","Lint the JSON before submission to catch syntax errors.","Keep the client's config schema in sync with the server's version."],"tags":["bitwarden","organization-connection","json","validation","scim","aspnet"],"backgroundTag":null,"analyzedSha":"e93b962371d80964556f5590c6615f5160a437a1","analyzedAt":"2026-08-13T14:22:19.382Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}