{"record":{"id":"c24ac13c8629d980","repo":"vercel/ai","slug":"acp-profile-data-must-resolve-to-an-object","errorCode":null,"errorMessage":"ACP profile data must resolve to an object.","messagePattern":"ACP profile data must resolve to an object\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/harness-acp/src/v1/bridge/protocol-configuration.ts","lineNumber":143,"sourceCode":"        : value;\n  }\n  return result;\n}\n\nfunction requireGateway({\n  gateway,\n}: {\n  gateway: ACPGatewayValues | undefined;\n}): ACPGatewayValues {\n  if (gateway == null) {\n    throw new Error('ACP Gateway profile values are unavailable.');\n  }\n  return gateway;\n}\n\nfunction asRecord(value: unknown): Readonly<Record<string, unknown>> {\n  if (!isRecord(value)) {\n    throw new Error('ACP profile data must resolve to an object.');\n  }\n  return value;\n}\n\nfunction isRecord(value: unknown): value is Readonly<Record<string, unknown>> {\n  return value != null && typeof value === 'object' && !Array.isArray(value);\n}\n","sourceCodeStart":125,"sourceCodeEnd":151,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/harness-acp/src/v1/bridge/protocol-configuration.ts#L125-L151","documentation":"asRecord coerces an unknown profile value to a readonly record and throws this error when the value is not a non-null, non-array object (isRecord fails). It protects downstream property access into ACP profile data.","triggerScenarios":"Passing a value that resolves to null, an array, or a primitive (string/number/boolean) where an object-shaped ACP profile record is expected, e.g. malformed JSON in a config file or a profile stored as a string.","commonSituations":"JSON config where the profile key holds a string or array instead of an object; an env var decoded to a scalar; a YAML list accidentally used where a mapping is required.","solutions":["Make the profile data a JSON/YAML object (mapping), not a scalar or array.","Parse the profile with a schema validator before handing it to the bridge.","Check for null (e.g. failed lookup returning null) and handle the missing-profile case at the call site."],"exampleFix":"// before\nconst profile = JSON.parse(rawProfileText); // rawProfileText is '\"dev\"'\n// after\nconst profile = JSON.parse(rawProfileText);\nif (profile == null || typeof profile !== 'object' || Array.isArray(profile)) {\n  throw new Error('Profile must be an object');\n}","handlingStrategy":"type-guard","validationCode":"const profile = rawProfile;\nif (profile == null || typeof profile !== 'object' || Array.isArray(profile)) {\n  throw new Error('ACP profile must be a non-null object');\n}","typeGuard":"function isRecord(value: unknown): value is Readonly<Record<string, unknown>> {\n  return value != null && typeof value === 'object' && !Array.isArray(value);\n}","tryCatchPattern":"try {\n  return resolved({ profile: parsed });\n} catch (error) {\n  if (error instanceof Error && error.message.includes('must resolve to an object')) {\n    throw new Error(`Invalid profile data: expected object, got ${typeof parsed}`);\n  }\n  throw error;\n}","preventionTips":["Parse profiles with a schema validator before use.","Avoid decoding config scalars/arrays where objects are expected.","Unit-test config loading with representative fixtures."],"tags":["acp","validation","configuration"],"backgroundTag":"schema-validation-failed","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}