Skip to content

fix: do not fail translate extract on link-included tocs - #2107

Open
martyanovandrey wants to merge 2 commits into
masterfrom
fix/translate-link-included-tocs
Open

fix: do not fail translate extract on link-included tocs#2107
martyanovandrey wants to merge 2 commits into
masterfrom
fix/translate-link-included-tocs

Conversation

@martyanovandrey

Copy link
Copy Markdown
Contributor

Problem

translate extract fails with Error while finding toc dir. on projects whose toc pulls in another toc via include: {mode: link} (DOCSTOOLS-6294).

Link-included tocs are inlined into their parent toc during translate, but they were also enumerated as standalone files. They stay as source nodes in the toc graph rather than toc nodes, so TocService.for() cannot resolve them and throws, aborting the whole extract.

Fix

Skip link-included tocs during translate file enumeration. Their strings are already extracted together with the parent toc, so extracting them separately only duplicated content on top of crashing.

The guard in Run.getFiles() keys off TocService.isToc(): a globbed toc.yaml that is not a real toc node is a link include and is dropped from the file list. Standalone tocs, merged tocs and non-toc yaml are unaffected.

A new e2e fixture (tests/mocks/translation/toc-include-link) with nested mode: link includes guards the regression - without the fix it reproduces the exact Error while finding toc dir. failures.

@martyanovandrey
martyanovandrey requested review from a team and diplodoc-bot as code owners July 24, 2026 12:44
@martyanovandrey
martyanovandrey requested review from reazy015 and stenin-nikita and removed request for a team July 24, 2026 12:44
@martyanovandrey
martyanovandrey force-pushed the fix/translate-link-included-tocs branch 2 times, most recently from 7f1ecc5 to 8a8be8c Compare July 24, 2026 13:00
@martyanovandrey
martyanovandrey force-pushed the fix/translate-link-included-tocs branch from 91d87ca to 1d63fb5 Compare July 27, 2026 13:19
Tocs pulled in with `include: {mode: link}` are inlined into their parent
toc during translate, but were still enumerated as standalone files. For
those files `TocService.for()` throws `Error while finding toc dir.`,
which failed the whole `translate extract` run (DOCSTOOLS-6294).

Skip link-included tocs in translate file enumeration - they stay as
`source` graph nodes and their strings are already extracted with the
parent toc, so extracting them on their own only duplicates content and
crashes.
The guard also fixes the default (merge) include mode: a section keeping
all articles in subdirectories never puts its own directory into the
merged-directories filter, so its absorbed toc leaked into the extraction
list and crashed the run. Add a fixture reproducing this layout and
generalize the guard comments accordingly.
@martyanovandrey
martyanovandrey force-pushed the fix/translate-link-included-tocs branch from 1d63fb5 to 4fd069c Compare July 28, 2026 09:56
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants