toeverything/AFFiNE · error
Invalid mobile payload token: empty file path
Error message
Invalid mobile payload token: empty file path
What it means
normalizeTokenFilePath validates mobile blob-file tokens; when the token's file path portion is empty after stripping the MOBILE_BLOB_FILE_PREFIX, the token is malformed and this Error is thrown. Used by normalizedPath.
Source
Thrown at packages/frontend/apps/mobile-shared/src/nbstore/payload.ts:16
import { base64ToUint8Array } from '@affine/core/modules/workspace-engine';
import { Capacitor } from '@capacitor/core';
export const MOBILE_BLOB_FILE_PREFIX = '__AFFINE_BLOB_FILE__:';
export const MOBILE_PAYLOAD_INLINE_THRESHOLD_BYTES = 1024 * 1024;
const MOBILE_PAYLOAD_CACHE_DIR = 'nbstore-blob-cache';
const MOBILE_PAYLOAD_BUCKET_PATTERN = /^[0-9a-f]{16}$/;
const MOBILE_PAYLOAD_FILE_PATTERN = /^[0-9a-f]{16}\.blob$/;
const MOBILE_PAYLOAD_PARENT_DIRS = new Set(['cache', 'Caches', 'T', 'tmp']);
const MOBILE_ANDROID_PACKAGE_PATTERN =
/^[A-Za-z][A-Za-z0-9_]*(\.[A-Za-z][A-Za-z0-9_]*)+$/;
function normalizeTokenFilePath(rawPath: string): string {
const trimmedPath = rawPath.trim();
if (!trimmedPath) {
throw new Error('Invalid mobile payload token: empty file path');
}
return trimmedPath.startsWith('file://')
? trimmedPath
: `file://${trimmedPath}`;
}
function assertMobileCachePath(fileUrl: string): void {
let pathname: string;
try {
const parsedUrl = new URL(fileUrl);
if (parsedUrl.protocol !== 'file:') {
throw new Error('unexpected protocol');
}
pathname = parsedUrl.pathname;
} catch {
throw new Error('Invalid mobile payload token: malformed file URL');
}View on GitHub (pinned to b4c8548c09)
Solutions
- Ensure the payload token contains a non-empty file path before calling the payload reader.
- Validate the token payload on the producer side so empty paths are never emitted.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown in normalizeTokenFilePath when a mobile nbstore blob payload token starts with the __AFFINE_BLOB_FILE__ prefix but the remainder trims to an empty string, so no file path can be derived.
Common situations: Seen on mobile when a corrupted or truncated blob reference is stored instead of a real cache file path. Re-fetching or re-uploading the blob regenerates a valid token.
AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18).
Data as JSON: /api/errors/29f6e1138a9c363e.
Report an issue: GitHub.