cockroachdb/cockroach · error · Error
Table ID is required
Error message
Table ID is required
What it means
getTableDetails in cluster-ui throws 'Table ID is required' before any network call when req.tableId is falsy (undefined, 0) or NaN. It guards the REST fetch to `${TABLE_METADATA_API_PATH}${req.tableId}/`, which would otherwise produce a malformed URL or a 404 for '/table_metadata/NaN/'. Typically the caller (useTableDetails SWR hook) received an unparsed or non-numeric id.
Source
Thrown at pkg/ui/workspaces/cluster-ui/src/api/getTableMetadataApi.ts:182
View on GitHub (pinned to 8812064a01)
Solutions
- Validate the route/prop before rendering the hook: parse once and fall back to an empty state if not a positive integer
- Pass the numeric metadata id (e.g. row's tableId field), not the table name
- Enforce numeric route patterns so unmatched URLs never reach the component
Example fix
// before
const tableId = Number(props.match.params.id);
const { data } = useTableDetails({ tableId });
// after
const tableId = Number(props.match.params.id);
if (!Number.isInteger(tableId) || tableId <= 0) {
return <EmptyState title='Select a table to see details' />;
}
const { data } = useTableDetails({ tableId }); Defensive patterns
Strategy: validation
Validate before calling
const tableId = Number(rawId);
if (!Number.isInteger(tableId) || tableId <= 0) {
return <EmptyState title='Select a table to see details' />;
}
const { data } = useTableDetails({ tableId }); Type guard
const isValidTableId = (id: unknown): id is number => typeof id === 'number' && Number.isInteger(id) && id > 0;
Try / catch
try {
const details = await getTableDetails(req);
} catch (e) {
if (e instanceof Error && e.message === 'Table ID is required') {
return <EmptyState title='Select a table to see details' />;
}
throw e;
} Prevention
- Derive tableId only from table metadata rows that guarantee a numeric id
- Enforce numeric route segments so bad URLs never mount the details component
- Default SWR hooks off until an id is confirmed valid (conditional keys)
When it happens
Trigger: Calling getTableDetails/useTableDetails with an id built from a missing route param (Number(undefined) = NaN), a non-numeric string id (Number('abc')), or an unset selection in the table details panel.
Common situations: Deep links to a table-details route where the id segment is empty or a table name instead of the numeric id; list rows that lack a tableId (dropped tables, views); details panel rendered before a row selection resolves.
Related errors
- Error while retrieving statements information: ${sqlApiError
- Error while retrieving statements information: ${sqlApiError
- Failed to collect execution details
- No schedule found with this ID.
- Multiple schedules found for ID.
AI-assisted analysis of cockroachdb/cockroach@8812064a01 (2026-08-15).
Data as JSON: /api/errors/fa823321f08bfd8a.
Report an issue: GitHub.