langfuse/langfuse · error · InvalidRequestError
Invalid dimension ${dimension.field}. Must be one of ${Objec
Error message
Invalid dimension ${dimension.field}. Must be one of ${Object.keys(view.dimensions)} What it means
handleDeleteMembership validates req.body against DeleteMembershipSchema before deleting. A body missing the required userId (or malformed) returns 400 'Invalid request body' with zod issue details.
Source
Thrown at packages/shared/src/features/query/server/queryBuilder.ts:281
dimension.explodeArray ||
dimension.pairExpand ||
dimension.aggregationFunction
) {
throw new InvalidRequestError(
`Invalid entity dimension: ${field}. Entity dimensions must be scalar view dimensions.`,
);
}
return dimension;
}
private mapDimensions(
dimensions: Array<{ field: string }>,
view: ViewDeclarationType,
): AppliedDimensionType[] {
return dimensions.map((dimension) => {
if (!(dimension.field in view.dimensions)) {
throw new InvalidRequestError(
`Invalid dimension ${dimension.field}. Must be one of ${Object.keys(view.dimensions)}`,
);
}
const dim = view.dimensions[dimension.field];
return {
...dim,
table: dim.relationTable || view.name,
explodeArray: dim.explodeArray,
pairExpand: dim.pairExpand,
};
});
}
private mapMetrics(
metrics: Array<{
measure: string;
aggregation: z.infer<typeof metricAggregations>;
}>,View on GitHub (pinned to 59d92c7cf3)
Solutions
- Send a JSON body containing userId on the DELETE request
- Include Content-Type: application/json
- Check details in the 400 response for the exact failing field
Example fix
// before
fetch(`/api/admin/organizations/${orgId}/memberships`, { method: 'DELETE' });
// after
fetch(`/api/admin/organizations/${orgId}/memberships`, {
method: 'DELETE',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ userId }),
}); Defensive patterns
Strategy: validation
Validate before calling
if (typeof userId !== 'string' || userId.length === 0) throw new Error('userId required in body');
await fetch(url, { method: 'DELETE', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ userId }) }); Type guard
function isDeleteMembershipBody(b: unknown): b is { userId: string } {
return typeof b === 'object' && b !== null && typeof (b as any).userId === 'string' && (b as any).userId.length > 0;
} Try / catch
const res = await fetch(url, { method: 'DELETE', ... });
if (res.status === 400) { /* inspect details, fix body */ } Prevention
- Remember this DELETE expects a JSON body
- Use the shared typed client for admin endpoints
- Test admin scripts against a staging org
When it happens
Trigger: DELETE to the admin memberships endpoint with an empty body or one lacking a valid userId.
Common situations: DELETE requests built without a JSON body because REST intuition says DELETE carries no body, or query-param-based clients after the contract moved to body.
Related errors
- Invalid entity dimension: ${field}. Must be one of ${Object.
- Invalid entity dimension: ${field}. Entity dimensions must b
- Invalid request body
- Invalid request body
- Invalid request body
AI-assisted analysis of langfuse/langfuse@59d92c7cf3 (2026-08-27).
Data as JSON: /api/errors/54a8b9b6fa05bc87.
Report an issue: GitHub.