Budibase/budibase · error · HTTPError
Project package contains invalid JSON in '${basename(filePat
Error message
Project package contains invalid JSON in '${basename(filePath)}'. What it means
readJsonFile reads a file from an extracted project package and JSON.parse's it; any parse or read failure is converted into this 400 HTTPError naming the offending file. It protects the import pipeline from corrupted or non-JSON files inside a .tar.gz project package.
Source
Thrown at packages/server/src/sdk/workspace/projects/backups/imports.ts:142
}
interface InsertedDocRef {
_id: string
_rev: string
}
interface ProjectPackageTarEntry {
path: string
type?: string
size?: number
resume?: () => void
}
const readJsonFile = async <T>(filePath: string): Promise<T> => {
try {
return JSON.parse(await fsp.readFile(filePath, "utf8"))
} catch {
throw new HTTPError(
`Project package contains invalid JSON in '${basename(filePath)}'.`,
400
)
}
}
const toTimestamp = (timestamp?: string | number) => {
if (timestamp == null) {
return undefined
}
const date = new Date(timestamp)
return Number.isNaN(date.getTime()) ? undefined : date.toISOString()
}
const getProjectCreatedAt = (project: Project) =>
toTimestamp(project.createdAt) ??
toTimestamp(project.updatedAt) ??
new Date().toISOString()View on GitHub (pinned to a81a902e9a)
Solutions
- Re-export the project from a healthy app and retry the import
- Validate the named file's JSON locally (jq or JSON.parse) to see the syntax problem
- Open/repair the file in the extracted package if hand-crafting the archive
- Confirm the package came from a compatible Budibase version
Example fix
// before // manifest.json last line: "name": "App", <- trailing comma // after // manifest.json last line: "name": "App" <- valid JSON, import succeeds
Defensive patterns
Strategy: validation
Validate before calling
const content = await fsp.readFile(filePath, "utf8")
try {
JSON.parse(content)
} catch (e) {
throw new Error(`${basename(filePath)} is not valid JSON: ${(e as Error).message}`)
} Type guard
function isJsonParsable(s: string): boolean {
try { JSON.parse(s); return true } catch { return false }
} Try / catch
try {
await importProject(packagePath)
} catch (e) {
if (e instanceof HTTPError && e.status === 400 && e.message.includes("invalid JSON")) {
// extract package, validate/repair the named file, repackage
} else throw e
} Prevention
- Checksum/verify downloaded export archives before import
- Never hand-edit package JSON without re-validating
- Match exporter and importer Budibase versions
When it happens
Trigger: Importing a project package where manifest.json, project.json, or the dependency index is truncated, empty, HTML (e.g. an error page saved as .json), contains comments/trailing commas, or was produced by an incompatible/older export format.
Common situations: Partial/corrupted downloads of the export archive; hand-editing package JSON and breaking syntax; exporting from a much older Budibase version and importing into a newer one; archiving tools mangling file contents.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Project package contains paths that are too deep.
- Project package contains too many files.
- Project package contains an invalid doc in '${basename(fileP
- Invalid import url
- Only HTTP(S) URLs are allowed for query import
AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29).
Data as JSON: /api/errors/16636b45859e4067.
Report an issue: GitHub.