vercel/ai · error
ACP profile data must resolve to an object.
Error message
ACP profile data must resolve to an object.
What it means
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.
Source
Thrown at packages/harness-acp/src/v1/bridge/protocol-configuration.ts:143
: value;
}
return result;
}
function requireGateway({
gateway,
}: {
gateway: ACPGatewayValues | undefined;
}): ACPGatewayValues {
if (gateway == null) {
throw new Error('ACP Gateway profile values are unavailable.');
}
return gateway;
}
function asRecord(value: unknown): Readonly<Record<string, unknown>> {
if (!isRecord(value)) {
throw new Error('ACP profile data must resolve to an object.');
}
return value;
}
function isRecord(value: unknown): value is Readonly<Record<string, unknown>> {
return value != null && typeof value === 'object' && !Array.isArray(value);
}
View on GitHub (pinned to 69428b1f8b)
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.
Example fix
// before
const profile = JSON.parse(rawProfileText); // rawProfileText is '"dev"'
// after
const profile = JSON.parse(rawProfileText);
if (profile == null || typeof profile !== 'object' || Array.isArray(profile)) {
throw new Error('Profile must be an object');
} Defensive patterns
Strategy: type-guard
Validate before calling
const profile = rawProfile;
if (profile == null || typeof profile !== 'object' || Array.isArray(profile)) {
throw new Error('ACP profile must be a non-null object');
} Type guard
function isRecord(value: unknown): value is Readonly<Record<string, unknown>> {
return value != null && typeof value === 'object' && !Array.isArray(value);
} Try / catch
try {
return resolved({ profile: parsed });
} catch (error) {
if (error instanceof Error && error.message.includes('must resolve to an object')) {
throw new Error(`Invalid profile data: expected object, got ${typeof parsed}`);
}
throw error;
} Prevention
- Parse profiles with a schema validator before use.
- Avoid decoding config scalars/arrays where objects are expected.
- Unit-test config loading with representative fixtures.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- ACP credentialEnv and credentialBrokering must be configured
- ACP credentialEnv and credentialBrokering must be configured
- ACP MCP server ${JSON.stringify(name)} must be configured wi
- ACP source.packageJson must not be empty.
- ACP source.pnpmLockYaml must not be empty.
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/c24ac13c8629d980.
Report an issue: GitHub.