hcengineering/platform · warning · Error
Error syncing .npmrc file: ${e}
Error message
Error syncing .npmrc file: ${e} What it means
loadCollabJson in foundations/server/packages/collaboration/src/storage.ts logs ctx.warn('invalid content type') when the blob's contentType does not include 'application/json'. Like its ydoc counterpart, it only warns and proceeds — the blob is read and returned as a string regardless. It flags that markup/JSON collaboration data is stored under an unexpected content type.
Source
Thrown at foundations/communication/common/scripts/install-run.js:223
// Ensure the target folder exists
if (!fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(targetNpmrcFolder)) {
fs__WEBPACK_IMPORTED_MODULE_0__.mkdirSync(targetNpmrcFolder, { recursive: true });
}
return _copyAndTrimNpmrcFile({
sourceNpmrcPath,
targetNpmrcPath,
logger,
...options
});
}
else if (fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(targetNpmrcPath)) {
// If the source .npmrc doesn't exist and there is one in the target, delete the one in the target
logger.info(`Deleting ${targetNpmrcPath}`); // Verbose
fs__WEBPACK_IMPORTED_MODULE_0__.unlinkSync(targetNpmrcPath);
}
}
catch (e) {
throw new Error(`Error syncing .npmrc file: ${e}`);
}
}
function isVariableSetInNpmrcFile(sourceNpmrcFolder, variableKey, supportEnvVarFallbackSyntax) {
const sourceNpmrcPath = `${sourceNpmrcFolder}/.npmrc`;
//if .npmrc file does not exist, return false directly
if (!fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(sourceNpmrcPath)) {
return false;
}
const trimmedNpmrcFile = _trimNpmrcFile({ sourceNpmrcPath, supportEnvVarFallbackSyntax });
const variableKeyRegExp = new RegExp(`^${variableKey}=`, 'm');
return trimmedNpmrcFile.match(variableKeyRegExp) !== null;
}
//# sourceMappingURL=npmrcUtilities.js.map
/***/ })
/******/ });
/************************************************************************/View on GitHub (pinned to 63e28dc964)
Solutions
- If the JSON parses fine downstream, treat this as informational and optionally correct the blob's contentType metadata.
- Confirm the blobId refers to the JSON/markup object and not another attachment.
- Re-write the document through the current API so it persists with contentType application/json.
- If consumers fail to parse the content, restore from backup or re-generate the markup data.
Defensive patterns
Strategy: validation
Validate before calling
const blob = await storageAdapter.stat(ctx, wsIds, blobId)
if (blob !== undefined && !blob.contentType.includes('application/json')) {
ctx.warn('refusing to load non-json blob as collaboration json', { blobId, contentType: blob.contentType })
} Type guard
function isJsonBlob(blob: { contentType: string } | undefined): blob is { contentType: string } & Record<string, unknown> {
return blob !== undefined && blob.contentType.includes('application/json')
} Try / catch
try {
const raw = await loadCollabJson(ctx, wsIds, blobId)
JSON.parse(raw)
} catch (err) {
// malformed or wrong content — restore from backup or regenerate the markup data
} Prevention
- Set contentType to application/json when writing markup/JSON collaboration blobs.
- Validate that stored content parses as JSON when adopting legacy data.
- Keep contentType metadata intact across migrations and restores.
When it happens
Trigger: A blobId resolved for collaboration JSON (e.g. markup) whose stat() contentType is not application/json — typically blobs written by older code paths or migrated without contentType metadata.
Common situations: Legacy data written before JSON content-type tagging; storage migration or backup restore dropping contentType; upload code failing to set contentType; the wrong blob id passed for a markup document.
Related errors
- Unexpected exception: could not detect node path or script p
- Failed to parse response for part ${partNumber}
- Failed to apply ydoc update
- Failed to upload collaborative document: ${id}
- WorkspaceUuid is not defined
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/a890909f41929156.
Report an issue: GitHub.