Skip to content

fix(deploy): upload Markdown as text/markdown - #5112

Merged
akira28 merged 1 commit into
mainfrom
fix/deploy-markdown-content-type
Dec 3, 2026
Merged

akira28 merged 1 commit into
mainfrom
fix/deploy-markdown-content-type

Conversation

@akira28

@akira28 akira28 commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Part of elastic/docs-eng-team#1231. Needed before elastic/docs-infra#537 can stop forcing Content-Type on *.md responses.

Why

The AWS SDK guesses each upload's Content-Type from its extension, and its table has no .md entry, so every Markdown page is stored as application/octet-stream. To serve them correctly, CloudFront's docs-shared-markdown response-headers policy forces text/markdown on every *.md response. That includes error pages, so once the docs 404 page comes from Lambda@Edge (elastic/docs-infra#530), a missing .md page would be labeled as Markdown.

Stored with the right type, CloudFront can serve .md responses as they are. elastic/docs-infra#537 switches *.md to a policy that adds headers only when missing, behind markdown_content_type_from_origin.

What changes

  • .md uploads get text/markdown; charset=utf-8, through the same per-type staging directories the spec files already use. The SDK shares one headers collection across a directory upload, so typed files never share one with other files.
  • SpecContentType is renamed ExplicitContentType, since it's no longer spec-only.

Existing objects

The sync only uploads files whose content changed, so .md objects already in the buckets keep application/octet-stream until they change. Before markdown_content_type_from_origin is turned on for an environment, its bucket needs a one-off in-place metadata rewrite:

aws s3 cp s3://elastic-docs-v3-website-<env>/docs/ s3://elastic-docs-v3-website-<env>/docs/ \
  --recursive --exclude '*' --include '*.md' \
  --content-type 'text/markdown; charset=utf-8' --metadata-directive REPLACE

Testing

  • ExplicitContentTypeTests covers .md, case-insensitive, along with the existing spec types, and checks that .txt, .html, .js and an extensionless md stay untyped.
  • Apply_SetsContentTypeOnTypedUploads checks that index.md goes up in its own text/markdown directory upload, separate from the untyped index.html.
  • All 68 tests in Elastic.Documentation.Deploying.Tests pass.

🤖 Generated with Claude Code

The AWS SDK has no .md entry in its MIME table, so .md pages were stored
as application/octet-stream and CloudFront had to force text/markdown on
every *.md response, error pages included. Upload them with an explicit
text/markdown; charset=utf-8 type, through the same per-type staging
directories as the spec files. SpecContentType becomes
ExplicitContentType since it is no longer spec-only.

Refs elastic/docs-eng-team#1231

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Docs preview (local build)

Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/5112/

@akira28
akira28 merged commit 142611f into main Dec 3, 2026
48 of 49 checks passed
@akira28
akira28 deleted the fix/deploy-markdown-content-type branch December 3, 2026 12:17

This branch was successfully deployed

2 active deployments
docs-preview — 8f4f4c3d Deployed Dec 3, 2026 by github-actions[bot]
assembler-preview — 8f4f4c3d Deployed Dec 3, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant