angular/angular-cli · error · Error
Relative pointer: ${pointer}
Error message
Relative pointer: ${pointer} What it means
parseJsonPointer parses RFC 6901-style JSON pointers, which must be absolute — every pointer starts with '/'. Passing a pointer that doesn't begin with '/' (or any non-empty non-absolute string) is rejected with 'Relative pointer: <pointer>'. An empty string is valid and resolves to the root.
Source
Thrown at packages/angular_devkit/core/src/json/schema/pointer.ts:31
fragments
.map((f) => {
return f.replace(/~/g, '~0').replace(/\//g, '~1');
})
.join('/')) as JsonPointer;
}
export function joinJsonPointer(root: JsonPointer, ...others: string[]): JsonPointer {
if (root == '/') {
return buildJsonPointer(others);
}
return (root + buildJsonPointer(others)) as JsonPointer;
}
export function parseJsonPointer(pointer: JsonPointer): string[] {
if (pointer === '') {
return [];
}
if (pointer.charAt(0) !== '/') {
throw new Error('Relative pointer: ' + pointer);
}
return pointer
.substring(1)
.split(/\//)
.map((str) => str.replace(/~1/g, '/').replace(/~0/g, '~'));
}
View on GitHub (pinned to bb72145f9a)
Solutions
- Prefix the pointer with '/': parseJsonPointer('/foo/bar')
- Build pointers from segments: '/' + segments.map(escape).join('/') where escape replaces ~ with ~0 and / with ~1
- Use '' (empty string) when you mean the document root
Example fix
// before
parseJsonPointer('properties/name')
// after
parseJsonPointer('/properties/name') Defensive patterns
Strategy: validation
Validate before calling
function assertAbsoluteJsonPointer(p: string): void {
if (p !== '' && !p.startsWith('/')) {
throw new Error(`Invalid JSON pointer (must start with '/'): ${p}`);
}
}
// call before parseJsonPointer / schema get operations Type guard
function isAbsoluteJsonPointer(p: string): p is `/${string}` {
return p === '' || p.startsWith('/');
} Try / catch
try {
const value = parseJsonPointer(pointer);
} catch (e) {
if ((e as Error).message.startsWith('Relative pointer:')) {
pointer = '/' + pointer.replace(/^\/+/, '');
// retry with normalized pointer
} else { throw e; }
} Prevention
- Build pointers from segments with a helper that escapes ~ and / instead of string concatenation
- Normalize user/schema $ref input to absolute pointers before passing to schema utilities
- Unit-test pointer helpers with empty string, nested, and escaped-token cases
When it happens
Trigger: Calling parseJsonPointer('foo'), parseJsonPointer('a/b'), or a value built by joining segments without a leading slash; passing a relative reference resolved against a base document instead of an absolute pointer.
Common situations: Hand-written pointers missing the leading slash, code concatenating property names like `${parent}/${key}` where parent is empty, JSON Schema $ref handling that receives relative refs, schema utility code (get/merge on JSON schema) fed user input.
Related errors
- Invalid config found at ${workspace.filePath}. CLI should be
- Unable to fetch package information for '${context.packageId
- Invalid option key: '${key}'. Option keys must be alphanumer
- --from requires that only a single package be passed.
- Could not parse package name from specifier: ${specifier}
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/8d38710c0b630852.
Report an issue: GitHub.