RocketChat/Rocket.Chat · error · Error
Invalid source path
Error message
Invalid source path
What it means
Thrown by `AppFileSystemSourceStorage.fetch()` when the `IAppStorageItem` has no `sourcePath`. The fetch operation translates a stored `sourcePath` (prefixed `fs:/...`) back to a filesystem filename; without a source path there is nothing to read. It indicates the storage item is incomplete or was never persisted via `store()`.
Source
Thrown at apps/meteor/ee/server/apps/storage/AppFileSystemSourceStorage.ts:34
public checkPath(): void {
if (!this.path) {
throw new Error('Invalid path configured for file system App storage');
}
}
public async store(item: IAppStorageItem, zip: Buffer): Promise<string> {
this.checkPath();
const filePath = this.itemToFilename(item);
await fs.writeFile(filePath, zip);
return this.filenameToSourcePath(filePath);
}
public async fetch(item: IAppStorageItem): Promise<Buffer> {
if (!item.sourcePath) {
throw new Error('Invalid source path');
}
return fs.readFile(this.sourcePathToFilename(item.sourcePath));
}
public async update(item: IAppStorageItem, zip: Buffer): Promise<string> {
this.checkPath();
const filePath = this.itemToFilename(item);
await fs.writeFile(filePath, zip);
return this.filenameToSourcePath(filePath);
}
public async remove(item: IAppStorageItem): Promise<void> {
if (!item.sourcePath) {
return;View on GitHub (pinned to f9d3ec372b)
Solutions
- Verify the storage item was created via `store()`/`update()` which assign a `sourcePath`.
- If the bundle is genuinely missing, re-install or re-upload the app so a source path is recorded.
- Guard callers with a `item.sourcePath` check before calling `fetch()`.
Example fix
// before
const buf = await storage.fetch(item); // throws if item.sourcePath missing
// after
if (!item.sourcePath) {
throw new Error('Cannot fetch app bundle: item has no sourcePath');
}
const buf = await storage.fetch(item); Defensive patterns
Strategy: validation
Validate before calling
function hasSourcePath(item: IAppStorageItem): boolean {
return Boolean(item?.sourcePath);
} Type guard
import type { IAppStorageItem } from '@rocket.chat/apps-engine/server/storage';
function hasValidSourcePath(item: unknown): item is IAppStorageItem & { sourcePath: string } {
return typeof (item as IAppStorageItem)?.sourcePath === 'string' && (item as IAppStorageItem).sourcePath.length > 0;
} Try / catch
if (!hasValidSourcePath(item)) {
throw new Error('Cannot fetch: item has no sourcePath');
}
const buf = await storage.fetch(item); Prevention
- Always persist app bundles via `store()` so `sourcePath` is set.
- Check `item.sourcePath` before calling `fetch()`.
- Treat missing sourcePath as a data-integrity issue and re-install the app.
When it happens
Trigger: Calling `fetch(item)` where `item.sourcePath` is undefined/null/empty — e.g. an app metadata record that was inserted without going through the source storage, or whose source bundle was never written.
Common situations: Reading an app record that predates the source-storage layer; a corrupted/partial install where metadata exists but the bundle reference is missing; test fixtures missing the `sourcePath` field.
Related errors
- Invalid path configured for file system App storage
- App already exists.
- Invalid Api parameter provided, it must be a valid IApi obje
- Invalid command parameter provided, must be a string.
- Invalid Slash Command parameter provided, it must be a valid
AI-assisted analysis of RocketChat/Rocket.Chat@f9d3ec372b (2026-08-12).
Data as JSON: /api/errors/43160915aa2454ab.
Report an issue: GitHub.