Describe the bug
When --path points at a docset that is not at the repository root, git checkout information is reported as unavailable even though the build is running inside an ordinary git checkout. DocumentationSet.Name then falls back to unknown-<sourceDirName>, and the site renders that string as the docset label.
The cause is that the --path value doubles as the ceiling for the git-root search, so the upward walk can never leave the docset directory:
https://github.com/elastic/docs-builder/blob/main/src/Elastic.Documentation.Configuration/Builder/BuildContext.cs#L114-L116
(DocumentationSourceDirectory, ConfigurationPath) = Paths.FindDocsFolderFromRoot(ReadFileSystem, rootFolder);
DocumentationCheckoutDirectory = Paths.FindGitRoot(DocumentationSourceDirectory, ceiling: rootFolder);
FindGitRoot starts at DocumentationSourceDirectory and is bounded by rootFolder, which is the --path value. When the docset lives below the git root, .git sits above that ceiling, so DocumentationCheckoutDirectory is null, Git becomes GitCheckoutInformation.Unavailable, and Name takes the fallback branch:
Name = Context.Git != GitCheckoutInformation.Unavailable
? Context.Git.RepositoryName
: Context.DocumentationCheckoutDirectory?.Name ?? $"unknown-{Context.DocumentationSourceDirectory.Name}";
Observed on a Codex preview for elastic/kibana, built with docs-builder 1.33.0 through elastic/docs-actions codex-preview.yml with path: docs-dev. The build log shows it plainly, and the rendered page carries unknown-docs-dev as the site label in the top left:
info ::DocumentationGenerator:: Created documentation set for: unknown-docs-dev
Two effects beyond the label, both from the same null DocumentationCheckoutDirectory:
HtmlWriter gates the per-page GitHub edit URL and the GitHub source URL on it being non-null, so those links are dropped from every page.
links.json records Origin as the Unavailable sentinel (branch, remote and ref all "unavailable") rather than the real branch and commit.
This is specific to builds that pass --path. codex build is unaffected, because it constructs GitCheckoutInformation explicitly from the clone (RepositoryName = checkout.Reference.Name) and roots the BuildContext at the repository directory, so the live site shows the correct name. That makes it a preview-only discrepancy, which is also why it is easy to miss.
It should affect any repository whose docset is not at the root. Among repos currently wired up to codex-preview that is security-team (docs-codex/), synthetics-service (docs-v3/), platform-engineering-productivity (new-docs/), infra (docs/resilience-team/) and kibana (docs-dev/).
This is not the same as #3136, which was about scope-root access to .git from a worktree.
Expected behavior
With the docset below the git root, the name resolves to the repository name (kibana in this case) and the GitHub edit/source links are emitted, matching what the same content produces when built by codex build.
The two concerns look conflated: --path is meaningful as the content scope root, but using it to bound git discovery means the enclosing repository becomes invisible precisely when the docset is nested. Letting git discovery walk to the enclosing repository, while leaving the content scope root where it is, would fix it — though the scope-root validation that produced #3136 suggests that walk needs to stay read-only and tolerate .git being a file or a link.
Steps to reproduce
- In a git checkout, place a docset in a subdirectory, for example
docs-dev/docset.yml.
- Run
docs-builder --path docs-dev --output ./.artifacts/docs/html.
- Observe
Created documentation set for: unknown-docs-dev in the log, and the same string as the site label in the rendered output.
Reproduced with docs-builder 1.33.0.
Tooling
Describe the bug
When
--pathpoints at a docset that is not at the repository root, git checkout information is reported as unavailable even though the build is running inside an ordinary git checkout.DocumentationSet.Namethen falls back tounknown-<sourceDirName>, and the site renders that string as the docset label.The cause is that the
--pathvalue doubles as the ceiling for the git-root search, so the upward walk can never leave the docset directory:https://github.com/elastic/docs-builder/blob/main/src/Elastic.Documentation.Configuration/Builder/BuildContext.cs#L114-L116
FindGitRootstarts atDocumentationSourceDirectoryand is bounded byrootFolder, which is the--pathvalue. When the docset lives below the git root,.gitsits above that ceiling, soDocumentationCheckoutDirectoryisnull,GitbecomesGitCheckoutInformation.Unavailable, andNametakes the fallback branch:Observed on a Codex preview for
elastic/kibana, built with docs-builder 1.33.0 throughelastic/docs-actionscodex-preview.ymlwithpath: docs-dev. The build log shows it plainly, and the rendered page carriesunknown-docs-devas the site label in the top left:Two effects beyond the label, both from the same null
DocumentationCheckoutDirectory:HtmlWritergates the per-page GitHub edit URL and the GitHub source URL on it being non-null, so those links are dropped from every page.links.jsonrecordsOriginas theUnavailablesentinel (branch,remoteandrefall"unavailable") rather than the real branch and commit.This is specific to builds that pass
--path.codex buildis unaffected, because it constructsGitCheckoutInformationexplicitly from the clone (RepositoryName = checkout.Reference.Name) and roots theBuildContextat the repository directory, so the live site shows the correct name. That makes it a preview-only discrepancy, which is also why it is easy to miss.It should affect any repository whose docset is not at the root. Among repos currently wired up to
codex-previewthat issecurity-team(docs-codex/),synthetics-service(docs-v3/),platform-engineering-productivity(new-docs/),infra(docs/resilience-team/) andkibana(docs-dev/).This is not the same as #3136, which was about scope-root access to
.gitfrom a worktree.Expected behavior
With the docset below the git root, the name resolves to the repository name (
kibanain this case) and the GitHub edit/source links are emitted, matching what the same content produces when built bycodex build.The two concerns look conflated:
--pathis meaningful as the content scope root, but using it to bound git discovery means the enclosing repository becomes invisible precisely when the docset is nested. Letting git discovery walk to the enclosing repository, while leaving the content scope root where it is, would fix it — though the scope-root validation that produced #3136 suggests that walk needs to stay read-only and tolerate.gitbeing a file or a link.Steps to reproduce
docs-dev/docset.yml.docs-builder --path docs-dev --output ./.artifacts/docs/html.Created documentation set for: unknown-docs-devin the log, and the same string as the site label in the rendered output.Reproduced with docs-builder 1.33.0.
Tooling