What an upload is validated against
Documentation reaches the doc service as a ZIP of a folder, and where each file sits in that folder is what decides where it is published. This page is the structural half of what checks that: the rules the doc service applies to the paths of an upload, per structure template - and for the tree of a static site, which follows none.
Two stages, and this is the second. Most of the content of the files - CommonMark, dead links, the
front-matter allowlist - is checked in the doc workflow, before anything is sent, and the doc service does not
read it again. The structure is checked here, against the template the upload names - and so, once the
structure is accepted, is one thing about a page's own content: whether its sidebar_position,
sidebar_after and sidebar_before are values this service can read at all, see
A page's own placement below. The doc workflow checks their shape too, but it is a
client a caller can skip, so this is the one check every upload goes through.
Ask before you build the ZIP. POST /api/uploads/docs/validation answers whether a path tree would be
accepted: 200 when there is nothing to report, 422 with a finding per problem when there is. Nothing is
uploaded, stored or read by it, and it has no side effect at all - see
the API.
The endpoint is advisory; the upload is not. A pipeline may skip the endpoint, and a hand-made ZIP is
refused all the same: the upload applies these rules to the paths of the archive it received, from the same
code, and answers 422 with the same findings. So this endpoint is what keeps a misfiled page out of a
build log rather than out of a site - the site is kept clean by the upload.
And a build applies them once more, to a set that is already stored. It is the backstop for a set that entered before a rule existed, or for a page whose name a template only started generating later: such a page is left out with a line in the build log, and never fails the build.
What is ignored, and never reported
A ZIP of a documentation folder carries files nobody wrote. They are dropped before any rule runs, and a pipeline is never failed for them:
| Ignored | Why |
|---|---|
.DS_Store, ._<name> | macOS Finder. The second is the sidecar carrying a file's resource fork |
__MACOSX/… | The directory macOS zip adds beside the real one |
Thumbs.db, desktop.ini | Windows Explorer |
.gitkeep, .gitignore | Git placeholders in a folder that would otherwise not exist |
<name>~, <name>.swp, .~lock.<name># | Editor backups and lock files |
A named list, not a pattern. Deliberately not "ignore every hidden file": one that is not on this list was written by somebody, and telling them about it beats dropping it in silence. The report says how many paths were ignored, because a count that omits what it skipped is no better than a truncated list.
A set that holds nothing else is empty, and answered EMPTY_TREE - the workflow's path is pointing at a
folder with no documentation in it.
What holds for every template
These rules are the doc service's, whatever template an upload names.
| # | Rule | Finding |
|---|---|---|
| 1 | The path is relative and normalized: no leading /, no .., no ., no empty segment, no backslash, no control character, no trailing /, at most 1024 characters | INVALID_PATH |
| 2 | No path appears twice | DUPLICATE_PATH |
| 3 | The path has at least two segments - a file at the root of the set belongs to no chapter, so nothing publishes it | FILE_OUTSIDE_CHAPTER |
| 4 | A page lies directly in its chapter, or in one group folder below it - see Groups. An asset may lie deeper, at most five folders below the chapter | NESTED_FOLDER |
| 5 | No file or folder name begins with . or _ - see below | HIDDEN_NAME, UNPUBLISHABLE_NAME |
| 6 | No file name is one the site generator reads as the chapter's landing page - index, readme or the chapter folder's own name, in any case - because the doc service writes that page. No folder right below the chapter carries a name the doc service writes there | RESERVED_NAME |
| 7 | No two documents of one chapter, or of one group, carry the same name once a leading number is taken off it - see below - and no file has the path of a folder another file of the set lies in | COLLIDING_NAME |
| 8 | The set holds at least one path that was not ignored | EMPTY_TREE |
Rules 3 to 7 are about a chapter, so they apply to a Markdown upload and not to an HTML one, which follows no chapters at all.
A number in front of a name is not part of the name
The site generator parses a leading number off a document's file name and publishes what is left: 01-rest-api.md
is the document rest-api, at the URL rest-api. Two consequences, and both are checked:
- a numbered name can be a reserved one.
01-rest-api.mdin5-building-block-view/is the page the doc service generates there, and01-index.mdis the chapter's generated landing page - both areRESERVED_NAME. - two names that differ only in their number are one document.
foo.mdbeside1-foo.md, or1-foo.mdbeside2-foo.md, are two files of the set and one page of the site, which fails the build of that part; both files are reported, because which of them to rename is the author's choice.
What looks like a date or a version is left alone, exactly as the generator leaves it alone: 2021-11-notes.md
and 7.0-notes.md are pages of their own name. The one rule that reads the name as written is the
landing-page rule above, because that is the name the generator asks it of: 1-intro.md in 1-intro/ is that
chapter's landing page, while intro.md in the same folder is an ordinary page at a URL of its own.
A name that will not be published
Two prefixes are refused, for two different reasons. They apply to the name of a file and to the name of every folder an asset lies in.
_ - because the site generator drops it. Docusaurus excludes _*.md from a docs build, and the names it
keeps for itself - _category_.json, which is a chapter's navigation - are its own. Either way an upload
carrying one succeeds and publishes something other than the page that was meant. UNPUBLISHABLE_NAME.
. - because a hidden file is not documentation. The ones a tool writes are ignored by name above, so
anything still beginning with a dot was written deliberately, and a documentation set has no business
carrying it. HIDDEN_NAME.
What is deliberately not checked
| Whether the system, component or library exists | It is created by the upload that names it |
| Whether a chapter is missing | Not an error: a repository documents what it documents, and no report mentions the chapters nobody wrote |
| Anything about a file's content, except its own placement | The workflow's half; this endpoint never receives a byte of a file, and these rules do not read one either - see A page's own placement for the one check that does |
| Whether the same tree was already uploaded | The endpoint has no memory and writes nothing |
| Case | A path is compared as it arrives, so 1-Intro/ is an unknown chapter. Saying so is more useful than accepting it into a case-sensitive object store. The exceptions are the extension and the landing page names of rule 6, which the site generator folds itself |
A page's own placement
A Markdown page may say where it goes among the other items of its chapter, in its front matter:
sidebar_position orders it among the items that carry no reference of their own; sidebar_after or
sidebar_before places it directly next to one other item by name. This runs only once the path structure
above is accepted, and only for a page the upload actually carries - never for the validation endpoint, which
receives a list of paths and no byte of any file's content.
| Rule | Finding |
|---|---|
sidebar_position is a finite number - an integer or a decimal, not quoted | INVALID_POSITION |
At most one of sidebar_after and sidebar_before is given, and the one that is names a single, non-blank name | INVALID_REFERENCE |
| Neither reference key is given on a static site's page - its pages are ordered by Docusaurus itself, with no chapter to place one next to | INVALID_REFERENCE |
sidebar_after or sidebar_before names a page of the same chapter of this set, a generated sibling of it, or a currently stored microsite of it | UNKNOWN_REFERENCE |
| A page's reference, followed from item to item - over this set's own pages and the chapter's currently stored microsites - does not loop back to itself | CYCLIC_ORDER |
The set this upload replaces does not count. An upload replaces its set whole, so a page that only the stored set has will be gone once the upload is taken over. A reference to it is refused, and a reference it still holds cannot close a cycle. A page that is moved therefore only has to say where it goes now. A microsite is a set of its own, so a stored microsite stays and counts.
The cross-reference checks run only for a system's, a component's or a library's documentation. A static
site's pages carry no reference at all - INVALID_REFERENCE already refuses one - so UNKNOWN_REFERENCE and
CYCLIC_ORDER never apply to one.
Groups
A folder directly below a chapter that holds at least one page is a group - one level, and reusing the
chapter's own rules one level down. A folder deeper down, or one holding assets only, is not: the former is
NESTED_FOLDER, the latter is exactly what a folder beside a page has always been.
A group's label and placement live in its own landing page - index.md, readme.md or a page named like
the group's folder, in any case, the same rule a chapter's landing page is read by. Its title is the group's
label, and its sidebar_position, sidebar_after or sidebar_before place the group among the chapter's
own items - a page, a generated sibling, a microsite or another group. A group with no uploaded landing page is
labelled by its own folder's stripped name and placed among the items with no reference; the site generator
writes a fallback landing page for it, listing its contents exactly as a chapter's own fallback does.
A reference resolves within its own level, never across it:
- At the chapter's level,
sidebar_after/sidebar_beforemay name a page of the chapter, a generated sibling, a microsite, or a group - by its stripped folder name. - Inside a group, a page's reference may name only another page of that same group. It cannot reach a page of the chapter, a generated sibling, a microsite, or another group's page - moving a page between levels means moving the file.
A group's own rules, on top of the ones above:
- At most one landing page. An index, a README, or a page named like the group's folder are all read as
the same document, so two of them collide at one route -
COLLIDING_NAME. - No two pages of one group carry the same name once a leading number is taken off it, the landing page's
identity included -
COLLIDING_NAME. - A group's own stripped name may not be the one a document of its chapter already has - a page named
shipping-partners.mdbeside a group foldershipping-partners/is one route -COLLIDING_NAME. Two groups whose stripped names collide are refused the same way. - A group folder right below the chapter may not carry a name the doc service writes there itself, exactly
as rule 6 above -
RESERVED_NAME. _category_.jsonstays refused inside a group too: the doc service writes it from the landing page's front matter, or from the generated fallback where there is none.
A page inside a group collides with nothing the chapter itself generates: a page named whitebox-view.md
inside a group is at a URL of its own, below the group's, never at the chapter's own generated route.
arc42
The template every jEAP repository uses today. Its rules are its own declarations - see Structure templates.
The chapter folders
A Markdown upload's first path segment is one of these twelve, and nothing else:
1-intro 7-deployment-view
2-constraints 8-crosscutting-concepts
3-context-and-scope 9-architecture-decision-records
4-solution-strategy 10-quality-requirements
5-building-block-view 11-risks
6-runtime-view 12-glossary
Anything else is UNKNOWN_CHAPTER, and where the folder is recognisably one of them written the wrong way -
runtime-view, 4-runtime-view, introduction - the message names the one it means. The name decides
before the number does: 4-runtime-view is answered with 6-runtime-view, the chapter it names, and not
with chapter 4. A number is what the guess falls back on when the name matches nothing, which is the case of a
folder written in another language.
The files it takes
md png jpg jpeg gif webp avif svg pdf txt csv json yaml yml
mdx is not among them and will not be: MDX is a programming language, and documentation the doc service
did not write itself is not trusted with one. Anything else is FORBIDDEN_EXTENSION, unless the instance adds
it with jeap.doc.custom.additional-asset-extensions - see Configuration.
An image lies beside the page that shows it, or in a folder inside the chapter.
5-building-block-view/overview.png next to 5-building-block-view/design.md is referenced as
, and 5-building-block-view/img/overview.png as .
A folder directly below the chapter may hold a page too - it is then a group - but a folder deeper
down holds assets only, and at most five folders below the chapter: a page there is a NESTED_FOLDER finding.
A folder is a name like a file's. The folder right below the chapter may not carry a name the doc service
writes into that chapter - 5-building-block-view/components/overview.png in a system's set would put the
picture into the generated tree of its components - and that is RESERVED_NAME. And one path is not both a
file and a folder: 1-intro/overview.png beside 1-intro/overview.png/small.png is COLLIDING_NAME on the
file, since no file system writes both.
A diagram is better written as a fenced plantuml, mermaid or dot block than uploaded as a picture: the
site renders it in the reader's browser, so it stays diffable, searchable and legible in both themes. The
image formats are for the pictures that have no source - a screenshot, a photograph, a scan.
A diagram drawn in an editor is the one case where a picture has a source, and the source is kept in the
repository rather than uploaded: images/overview.drawio beside the images/overview.svg exported from it.
Its extension is not among the ones above on purpose, so an upload that carried one would be
FORBIDDEN_EXTENSION - and that is the safety net rather than the rule. The rule is the doc pipeline's: it
leaves the sources out of the bundle, and it refuses a set whose source was committed after its image, on the
assumption that the author forgot to export it. The service cannot check that: it is told the paths of a
bundle, not the history of the repository the bundle came from. See Documentation validation in
jeap-pipeline.
The other files are ones a page links to rather than shows - a specification, sample data, an example payload or
configuration: [The API specification](https://github.com/jeap-admin-ch/jeap-doc-service/blob/main/docs/files/api-spec.pdf).
What the generator writes, and an upload may not
A page of one of these names would produce two documents at one URL. The site is built with
onDuplicateRoutes: 'throw', so it fails the build of that system's part - twenty minutes later, naming a
route rather than an upload, while the team's documentation stops updating. That is what RESERVED_NAME
prevents.
| Chapter | System docs | Component docs | Library docs |
|---|---|---|---|
1-intro | not-in-the-architecture-model | not-in-the-architecture-model | library-overview |
3-context-and-scope | system-context-view | context-view | - |
5-building-block-view | whitebox-view, components, libraries, events, commands | database-schema, rest-api, messages | - |
6-runtime-view | system-reactions | component-reactions | - |
Four of those are folders rather than pages - components, libraries, events, commands - and they are
reserved for the same reason: a folder with a landing page and a file of that name are one URL.
not-in-the-architecture-model is reserved whether or not the model holds the subject. It is the page a
system or component gets when nothing is deployed yet and the architecture model therefore knows nothing
about it. Reserving it only while the model is silent would make one and the same upload valid on one day and
invalid on the next, decided by an import rather than by anything a team did.
Plus, in every chapter of every template, the names the site generator reads as that chapter's landing page:
index, readme and the chapter folder's own name - 1-intro/1-intro.md. Those three are folded, because the
generator folds them: README.md and INDEX.MD are the same page to it.
A library gets one generated page, 1-intro/library-overview.md: the version, the repository, the branch
and the commit its upload named. Nothing else about a library is generated - no architecture model holds one -
so all twelve of its chapters are the team's to write, and its upload is bounded by the rules that hold for
every template, the extensions above, and that one name.
Only a .md can collide. Only Markdown becomes a document, so
5-building-block-view/whitebox-view.png is an image that no page is served at and is accepted.
An HTML upload follows no template
HTML is a source format, not a second template: an upload names source-format=html and a template,
because its location is a chapter of that template. What is published is the tree as it is, in an iframe, so
it follows none of the chapter rules and may nest as deeply as any built site.
| # | Rule | Finding |
|---|---|---|
| 1 | The path is relative and normalized, as above | INVALID_PATH |
| 2 | No path appears twice | DUPLICATE_PATH |
| 3 | The extension is not one a workstation runs | FORBIDDEN_EXTENSION |
| 4 | index.html lies at the root of the set | MISSING_ENTRY_POINT |
| 5 | location names a chapter folder of the named template | UNKNOWN_LOCATION |
| 6 | No _jeap-search.tsv at the root of the set | RESERVED_PATH |
exe com cmd bat msi scr lnk reg ps1 psm1 vbs vbe wsf sh bash zsh
jar dll so dylib app deb rpm apk pkg dmg
A microsite follows no allowlist, because it follows no template: it is published as it is, and a build
emits file types nobody listed in advance - a source map, a web manifest, a LICENSE with no extension at
all, and the Markdown or CSV a generated report links to. What is refused is what a workstation runs, and an
instance may set its own list with
jeap.doc.custom.refused-extensions. _astro/, _next/
and .well-known/ are accepted - a static export's own directories are its business, and none of them goes
through the docs build.
What bounds what a microsite may do is not this list: it is served with an opaque origin and framed in a sandbox - see Security.
One name is the service's own. _jeap-search.tsv at the root of a set is where the text of the
microsite's pages is stored when it is uploaded, under the same prefix as its files so that removing the set
removes it too - so a set carrying that path is refused rather than silently overwritten. Deeper in the tree
the name is a team's own business.
A static site's tree follows no template
A static site's tree (type=site-docs) is published as it is, so there are no chapters: a file may lie at the
root and in any folder, at any depth. Its report names static-site as its template and lists no folders. What
still holds is what holds for every Markdown set:
| # | Rule | Finding |
|---|---|---|
| 1 | The path is relative and normalized, as above | INVALID_PATH |
| 2 | No path appears twice | DUPLICATE_PATH |
| 3 | No file or folder name begins with . or _ - except a folder's _category_.json, which labels and orders it | HIDDEN_NAME, UNPUBLISHABLE_NAME |
| 4 | The extension is one a page or its assets are written in: md, png, jpg, jpeg, gif, webp, avif, svg, pdf, txt, csv, json, yaml, yml, and what the instance adds | FORBIDDEN_EXTENSION |
| 5 | No path is both a file and a folder, and no two pages are published at one URL: a leading number is not part of a URL, and an index, a README or a page named like its folder - compared as written, before a number comes off, so 01-guides/01-guides.md is the folder's page and 01-guides/guides.md is not - is the folder's own page | COLLIDING_NAME |
| 6 | No page takes a URL the doc service serves on every static site itself: about-this-documentation and search at the root, as a page or as a folder's own page | RESERVED_NAME |
| 7 | No page lies in a folder the doc service answers below every site's root: microsites and pagefind, tags, where the generator writes a page per tag, and assets, img and branding, which are published once per site rather than with its build - and on the default site, which is served at the context root, also site, api, actuator, swagger-ui, api-docs, webjars and error | RESERVED_NAME |
An index.md or README.md at the root is the tree's own root page and replaces the generated one. A site-level
tree is checked for its site, which has to be a static site, exactly as the upload checks it. Ask with
POST /api/uploads/docs/validation?site=<id>&type=site-docs&source-format=markdown.
The finding codes
What a pipeline branches on. Every finding names the path it is about, except the four that are about the set as a whole.
| Code | What it means |
|---|---|
INVALID_PATH | Not a relative, normalized path, or longer than 1024 characters |
RESERVED_PATH | A path the doc service writes itself, which a set may not bring |
DUPLICATE_PATH | The same path appears more than once |
FILE_OUTSIDE_CHAPTER | A file at the root of the set, belonging to no chapter |
UNKNOWN_CHAPTER | The first segment is not a chapter of the template |
NESTED_FOLDER | A page more than one folder below its chapter, or an asset more than five folders below it |
HIDDEN_NAME | A file or folder name beginning with a dot |
UNPUBLISHABLE_NAME | A file or folder name beginning with an underscore |
FORBIDDEN_EXTENSION | An extension the template does not take, or one a microsite refuses |
RESERVED_NAME | A document of a name the doc service generates into that chapter, or one the site generator reads as the chapter's landing page - a leading number is taken off the name first. Or a folder right below the chapter of such a name |
COLLIDING_NAME | Two documents of one chapter, or of one group, that the site generator would publish at one URL, because a leading number is not part of a page's name - a group's own stripped name included. Or a file at the path of a folder another file of the set lies in |
UNKNOWN_TEMPLATE | Set-level. No template of that name exists; the message names the ones that do |
EMPTY_TREE | Set-level. Nothing in the set would be published |
MISSING_ENTRY_POINT | Set-level. An HTML upload with no index.html at its root |
UNKNOWN_LOCATION | Set-level. An HTML upload embedded at something that is not a chapter |
INVALID_POSITION | sidebar_position is there and is not a finite number |
INVALID_REFERENCE | sidebar_after and sidebar_before both given, one of them given with a value that is not a single, non-blank name, or either given on a static site's page |
UNKNOWN_REFERENCE | sidebar_after or sidebar_before names something that is not a page of the same chapter of this set, a generated sibling of it, or a currently stored microsite of it |
CYCLIC_ORDER | A page's reference, followed from item to item, loops back to itself - a self-reference is a cycle of one |
Adding a template
A second structure template declares three things and writes no validation code at all:
| Its chapters | chapters(), which it already declares to generate into |
| The extensions an upload may carry | allowedFileExtensions() |
| What it generates into a chapter, if anything, in the order it writes them | generatedSiblings(chapter, subject), which defaults to nothing |
Everything else - the path rules, the finding codes, the messages, the order and the cap - is the doc service's, so the workflow that prints arc42's report prints the new template's unchanged. See Structure templates for what a template is, and the API for the endpoint.
Related
- The API - the endpoint, its parameters and its answers
- Uploads - how a documentation set reaches the doc service
- The documentation a team writes - what becomes of a set that passes these rules
- Structure templates - what a template is, and how to add one
- Generating the documentation - what the doc service writes itself