nodejs/node · error · Exception

Only relative paths are supported in includes

Error message

Only relative paths are supported in includes

What it means

The inspector-protocol PDL parser supports an `include <path>` directive that textually pulls another protocol file into the current one. pdl.py refuses absolute paths so includes stay relocatable and cannot escape the source tree; an absolute include also breaks the os.path.join used to resolve it.

Source

Thrown at deps/inspector_protocol/pdl.py:97

      nukeDescription = True

    if len(trimLine) == 0:
      continue

    match = re.compile(
        r'^(experimental )?(deprecated )?domain (.*)').match(line)
    if match:
      domain = createItem({'domain' : match.group(3)}, match.group(1),
                          match.group(2))
      protocol['domains'].append(domain)
      continue

    match = re.compile(
        r'^include (.*)').match(line)
    if match:
      included_filename = match.group(1)
      if os.path.isabs(included_filename):
        raise Exception("Only relative paths are supported in includes")
      resolved_path = os.path.normpath(os.path.join(os.path.dirname(file_name), included_filename))
      with open(resolved_path, 'r') as file:
        included_data = parse(file.read(), resolved_path, map_binary_to_string, source_set)
        protocol['domains'].extend(included_data['domains'])
      continue

    match = re.compile(r'^  depends on ([^\s]+)').match(line)
    if match:
      if 'dependencies' not in domain:
        domain['dependencies'] = []
      domain['dependencies'].append(match.group(1))
      continue

    match = re.compile(r'^  (experimental )?(deprecated )?type (.*) '
                       r'extends (array of )?([^\s]+)').match(line)
    if match:
      if 'types' not in domain:
        domain['types'] = []

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Rewrite the include directive to use a path relative to the file containing it (e.g. `include ../browser_protocol.pdl`).
  2. Fix the generator/template that emitted the absolute path so it emits repo-relative paths.
  3. Validate .pdl files in CI with a grep for `^include /` to catch regressions.

Example fix

# before
include /home/me/src/js_protocol.pdl
# after
include js_protocol.pdl
Defensive patterns

Strategy: validation

Validate before calling

import os
for line in open(protocol_file):
    if line.startswith('include '):
        path = line[len('include '):].strip()
        assert not os.path.isabs(path), f'include must be relative: {path}'

Prevention

When it happens

Trigger: Raised inside parse() when a line matches `^include (.*)` and `os.path.isabs(included_filename)` is true for the captured path.

Common situations: Hand-authored or generated .pdl that used a full /home/user/... or C:\... path in an include line; tooling that emitted absolute paths when stitching protocol fragments; vendored protocol files edited on Windows with drive letters.

Related errors


AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13). Data as JSON: /api/errors/2f9e28ca838a80c9. Report an issue: GitHub.