Skip to content

Bug: Diffing fails when StrictDoc root is not at git repo root level #2743

@larsjohansson-saferadar

Description

Describe the bug

If I define a custom grammar, and if I have placed my strictdoc requirements structure in a repo, but placed it in a subdirectory structure below the git root, then the the diffing functionality stops working. The error message indicates that the grammar file cannot be found.

To Reproduce

See discussion in https://discord.com/channels/793487244316770326/793487244316770329/1481588951226646579

  • Create a repo and with a multilevel folder structure.
  • Place the strictdoc files at a lower level.
  • Create commits
  • Create a commit introducing a custom grammar and refer to it from the strictdoc_config.py file.
  • Diffing between commits works until the commit where you introduced the custom grammar.
  • Note: Diffing continues to work if you compare commits prior to the custom grammar introduction.

See enclosed minimal example:
minimal_example.tar.gz

Expected behavior

  • Strictdoc should be able to find directory structures and referenced files in the LHS and RHS trees, and diff them, provided that the strictdoc roots are at the same paths in both commits. StrictDoc should not impose restrictions on where I want store the requirements structure in my repo.
  • Exception: If the strictdoc files are moved around the repository to a new location, it is acceptable that the diffing breaks, but the error message should be clearer and not complain specifically about the grammar file.
  • Secondary: It should be possible to have multiple strictdoc structures in the same repo.

Screenshots

Failing output:

INFO:     127.0.0.1:42940 - "GET /diff_result?tab=diff&left_revision=HEAD%5E&right_revision=HEAD HTTP/1.1" 500 Internal Server Error
ERROR:    Exception in ASGI application
...
File "/--- REMOVED --- /python3.12/site-packages/strictdoc/core/traceability_index_builder.py", line 394, in create_from_document_tree
    raise StrictDocException(
strictdoc.helpers.exception.StrictDocException: TraceabilityIndex: the document "Doc 1" imports a grammar from a file that does not exist: "@project_grammar". One known source of this error is when only a single document file is provided as input to the export or server command, rather than the containing folder. To locate the grammar file, StrictDoc needs to be able to resolve it relative to the input path.

Environment

$ strictdoc --version
$ uname -a
Linux SR-LJ-01 6.6.87.2-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC Thu Jun  5 18:30:46 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux

Additional context

Diffing fails both from the command line and browser.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions