RocketChat/Rocket.Chat · error
Failed to parse app.json: ${e instanceof Error ? e.message :
Error message
Failed to parse app.json: ${e instanceof Error ? e.message : String(e)} What it means
Thrown by getAppManifest when JSON.parse fails on the contents of app.json from the unzipped archive. The file exists (the 'No app.json' check passed) but its content is not valid JSON. The error message includes the underlying parse error message for debugging. strFromU8 converts the raw bytes to a UTF-8 string before parsing.
Source
Thrown at apps/meteor/client/views/marketplace/lib/getManifestFromZippedApp.ts:28
fileReader.onload = (e): void => resolve(new Uint8Array((e.target as any).result as Uint8Array));
fileReader.onerror = (e): void => reject(e);
fileReader.readAsArrayBuffer(file);
});
}
function unzipAppBuffer(zippedAppBuffer: Uint8Array): Uint8ArrayObject {
return unzipSync(zippedAppBuffer);
}
function getAppManifest(unzippedAppBuffer: Uint8ArrayObject): AppManifestSchema {
if (!unzippedAppBuffer['app.json']) {
throw new Error('No app.json file found in the zip');
}
try {
return JSON.parse(strFromU8(unzippedAppBuffer['app.json']));
} catch (e) {
throw new Error(`Failed to parse app.json: ${e instanceof Error ? e.message : String(e)}`);
}
}
async function unzipZippedApp(zippedApp: File | Uint8Array): Promise<Uint8ArrayObject> {
try {
if (zippedApp instanceof File) {
zippedApp = await fileToUint8Array(zippedApp);
}
return unzipAppBuffer(zippedApp);
} catch (e) {
console.error(e);
throw e;
}
}
export async function getManifestFromZippedApp(zippedApp: File): Promise<AppManifestSchema> {
const unzippedBuffer = await unzipZippedApp(zippedApp);View on GitHub (pinned to f9d3ec372b)
Solutions
- Validate app.json with a JSON linter or jsonlint before packaging the app.
- Ensure app.json is UTF-8 encoded without BOM.
- Use the rc-apps build tool which validates the manifest during build.
- Read the error message embedded in the thrown error to find the exact JSON syntax issue.
Example fix
// before: app.json with trailing comma
// { "id": "myapp", "version": "1.0.0", }
// after: valid JSON
// { "id": "myapp", "version": "1.0.0" } Defensive patterns
Strategy: try-catch
Validate before calling
const raw = strFromU8(unzippedAppBuffer['app.json']);
try {
JSON.parse(raw);
} catch (e) {
console.error('app.json parse error:', e.message);
// show specific JSON validation error to the developer
} Type guard
const isValidJson = (str: string): boolean => {
try { JSON.parse(str); return true; } catch { return false; }
}; Try / catch
try {
const manifest = await getManifestFromZippedApp(zipFile);
} catch (e) {
if (e instanceof Error && e.message.startsWith('Failed to parse app.json')) {
// e.message contains the underlying JSON parse error for debugging
showManifestParseError(e.message);
return;
}
throw e;
} Prevention
- Validate app.json with a JSON linter before packaging.
- Ensure app.json is UTF-8 encoded without BOM.
- Use rc-apps build which validates the manifest format.
- Read the embedded parse error message to pinpoint syntax issues.
When it happens
Trigger: The app.json file has a JSON syntax error (trailing comma, unquoted keys, single quotes, missing braces). The file is not actually JSON (e.g., it is YAML, TOML, or plain text that was misnamed). Encoding issue: the file is UTF-16 or has a BOM that breaks JSON.parse. The file is empty or truncated.
Common situations: Developer hand-edits app.json and introduces a syntax error. Build tool misconfigures the manifest format. File encoding mismatch (UTF-16 from Windows editors). Corrupted download/transfer. Minification or transformation tool mangled the JSON.
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
- No app.json file found in the zip
- ${result.error}
- error-invalid-params-custom
- invalid-field-content
- Integration payload must be a JSON object, not an array or p
AI-assisted analysis of RocketChat/Rocket.Chat@f9d3ec372b (2026-08-12).
Data as JSON: /api/errors/1e66744c1dbb8b67.
Report an issue: GitHub.