Skip to content

fix(scripts): resolve slug collision in cross-post manifest - #13

Merged
RickCogley merged 1 commit into
mainfrom
fix/crosspost-slug-collision
Apr 17, 2026
Merged

fix(scripts): resolve slug collision in cross-post manifest#13
RickCogley merged 1 commit into
mainfrom
fix/crosspost-slug-collision

Conversation

@RickCogley

Copy link
Copy Markdown
Member

Summary

  • Cross-post scripts were deriving the manifest key from `basename(file, ".md")`, which collides when files follow the common `{article-slug}/devto.md` / `{article-slug}/qiita.md` convention — every article produced the same key (`"devto"` / `"qiita"`), causing subsequent crosspost runs in `--update` mode to silently overwrite prior articles on Dev.to / Qiita.
  • Extracted `deriveSlug()` helper that falls back to the parent directory name when the filename is one of the generic names `devto` / `qiita`. Standalone `.md` files keep the previous filename-based behaviour.
  • Applied identically to `cross-post-devto.mts` and `cross-post-qiita.mts`.

Closes #12

Test plan

  • Manually traced logic for three cases:
    • `my-article/devto.md` → slug `"my-article"` ✓
    • `my-article/qiita.md` → slug `"my-article"` ✓
    • `standalone-article.md` → slug `"standalone-article"` (backwards-compat)
  • Downstream verify: after sync to `RickCogley/pub-cogley`, re-run a crosspost for an existing tracked article in `--dry-run` mode; the console output should show the article's real slug (e.g. `slug: japan-ipa-security-action-sme`) rather than the generic `slug: devto` it showed before.

Notes

Bug surfaced in `RickCogley/pub-cogley` while cross-posting the `japan-ipa-security-action-sme` article — overwrote the prior `engineering-backpressure-ai-code-quality` Dev.to article and caused a duplicate Qiita draft. Manual recovery done; this PR prevents recurrence.

When crosspost markdown files follow the convention
{article-slug}/devto.md or {article-slug}/qiita.md, basename() alone
yields a generic key ("devto" / "qiita") that collides across articles
in the manifest. A subsequent crosspost run in --update mode overwrites
the prior article on Dev.to / Qiita with the new content.

Fix: extract a deriveSlug() helper that falls back to the parent
directory name when the filename is one of the generic crosspost
names. Standalone .md files (named by slug directly) continue to work
unchanged.

Closes #12

InfoSec: integrity fix — prevents silent overwrite of published
external content; no security-sensitive code paths touched.
@RickCogley
RickCogley merged commit 69f39be into main Apr 17, 2026
3 checks passed
@RickCogley
RickCogley deleted the fix/crosspost-slug-collision branch April 17, 2026 06:29
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.

Cross-post scripts: slug collision when filename is devto.md or qiita.md

1 participant