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

  1. Prefix the pointer with '/': parseJsonPointer('/foo/bar')
  2. Build pointers from segments: '/' + segments.map(escape).join('/') where escape replaces ~ with ~0 and / with ~1
  3. 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

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


AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30). Data as JSON: /api/errors/8d38710c0b630852. Report an issue: GitHub.