Budibase/budibase · error · Error
Must supply either a view ID or a table ID
Error message
Must supply either a view ID or a table ID
What it means
The rows `search` function requires exactly one data source: a view ID or a table ID. When neither option is supplied it throws a plain Error telling the caller to provide one.
Source
Thrown at packages/server/src/sdk/workspace/rows/search.ts:70
sortOrder: options.sortOrder,
sortType: options.sortType,
limit: options.limit,
bookmark: options.bookmark,
paginate: options.paginate,
fields: options.fields,
countRows: options.countRows,
})
let source: Table | ViewV2
let table: Table
if (options.viewId) {
source = await sdk.views.get(options.viewId)
table = await sdk.views.getTable(source)
} else if (options.tableId) {
source = await sdk.tables.getTable(options.tableId)
table = source
} else {
throw new Error(`Must supply either a view ID or a table ID`)
}
const isExternalTable = isExternalTableID(table._id!)
if (options.query) {
const visibleFields = (
options.fields || Object.keys(table.schema)
).filter(field => table.schema[field]?.visible !== false)
const queryableFields = await getQueryableFields(table, visibleFields)
validateFilters(options.query, queryableFields)
} else {
options.query = {}
}
if (context) {
options.query = await enrichSearchContext(options.query, context)
}View on GitHub (pinned to a81a902e9a)
Solutions
- Pass options.tableId with a valid table ID
- Or pass options.viewId with a valid view ID
- Log/inspect the options object to confirm the ID key is spelled correctly and populated
Example fix
// before
await sdk.rows.search({ query: {} })
// after
await sdk.rows.search({ tableId: 'ta_...', query: {} }) Defensive patterns
Strategy: validation
Validate before calling
if (!options.tableId && !options.viewId) throw new Error('search requires tableId or viewId') Type guard
function hasSearchSource(o: { tableId?: string; viewId?: string }): o is { tableId: string } | { viewId: string } { return !!o.tableId || !!o.viewId } Try / catch
try { await sdk.rows.search(opts) } catch (e) { if (e.message.includes('Must supply either a view ID or a table ID')) { /* fix options */ } else throw e } Prevention
- Type search options so tableId or viewId is required
- Default tableId from route/context before calling
- Validate options objects constructed dynamically
When it happens
Trigger: Calling sdk.rows.search({}) or omitting both `viewId` and `tableId` in the options object.
Common situations: Programmatically constructed search options where the ID variable is undefined; API requests missing query/body params; refactors that renamed the option keys.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- Error getting status
- Unable to remove doc without a valid _id and _rev.
- Cannot store document without _id field.
- Configuration invalid. Must contain google clientID and clie
- Configuration invalid. Must contain clientID, clientSecret,
AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29).
Data as JSON: /api/errors/e1857a5273cdad54.
Report an issue: GitHub.