Budibase/budibase · error
gotoFunc must be a function, found a "${typeof gotoFunc}" in
Error message
gotoFunc must be a function, found a "${typeof gotoFunc}" instead What it means
The navigation store is initialized with a SvelteKit-style goto function injected via init(gotoFunc). To fail fast on misconfiguration, init validates the argument is actually a function before storing it, throwing with the found typeof value otherwise.
Source
Thrown at packages/builder/src/stores/portal/navigation.ts:20
type GotoFuncType = (path: string) => void
interface NavigationState {
initialisated: boolean
goto: GotoFuncType
}
class NavigationStore extends BudiStore<NavigationState> {
constructor() {
super({
initialisated: false,
goto: undefined as any,
})
}
init(gotoFunc: GotoFuncType) {
if (typeof gotoFunc !== "function") {
throw new Error(
`gotoFunc must be a function, found a "${typeof gotoFunc}" instead`
)
}
this.set({
initialisated: true,
goto: gotoFunc,
})
}
}
export const navigation = new NavigationStore()
View on GitHub (pinned to a81a902e9a)
Solutions
- Pass the actual goto function, e.g. import { goto } from "@svelterouter/kit"-style source and call navigation.init(goto)
- Check the import — ensure it destructures the function, not the module
- Ensure init is called in the right lifecycle where goto is defined
- In tests, provide a jest.fn() mock as the gotoFunc
Example fix
// before
import * as nav from "$app/navigation"
navigation.init(nav)
// after
import { goto } from "$app/navigation"
navigation.init(goto) Defensive patterns
Strategy: validation
Validate before calling
if (typeof goto !== "function") {
throw new Error("navigation.init requires a goto function")
}
navigation.init(goto) Type guard
const isGotoFunc = (f: unknown): f is GotoFuncType => typeof f === "function"
Try / catch
try {
navigation.init(goto)
} catch (e) {
if (e.message.includes("gotoFunc must be a function")) {
console.error("Check the goto import — expected the function, not the module")
} else throw e
} Prevention
- Import goto as a named function import, not a namespace import
- Call init() at app bootstrap where goto is guaranteed defined
- Add a unit test asserting navigation init receives a function
- In tests, pass jest.fn() as the gotoFunc mock
When it happens
Trigger: Calling init() with undefined/null (forgetting to pass goto), or passing a non-function such as a string path, an object, or a wrongly-imported module instead of the goto function.
Common situations: Bad import of goto (importing the module namespace rather than the function); calling init before SvelteKit context is available; refactor renamed/moved goto and the call site wasn't updated; testing setup not providing a mock goto.
Related errors
- Source table '${relationship.sourceTable}' not found in data
- Target table '${relationship.targetTable}' not found in data
- Invalid custom REST template
- automationId and appId are required
- Query ID or Revision is missing
AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29).
Data as JSON: /api/errors/1320c6de5d9deb9d.
Report an issue: GitHub.