[PR #1351] [MERGED] fix(tags): normalise leading hashes in tag names (#1317) #1806

Closed
opened 2026-03-02 11:59:16 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/karakeep-app/karakeep/pull/1351
Author: @mostafa-wahied
Created: 5/3/2025
Status: Merged
Merged: 6/22/2025
Merged by: @MohamedBassem

Base: mainHead: fix/normalize-tag-leading-hash-1317


📝 Commits (4)

  • c95d349 fix(tags): normalise leading hashes in tag names (#1317)
  • fc81658 Merge branch 'main' into fix/normalize-tag-leading-hash-1317
  • 887569a move the transformation to zod
  • 6404268 fix openapi spec

📊 Changes

5 files changed (+56 additions, -7 deletions)

View changed files

📝 packages/open-api/karakeep-openapi-spec.json (+1 -2)
📝 packages/shared/types/tags.ts (+9 -2)
packages/shared/utils/tag.ts (+6 -0)
📝 packages/trpc/routers/bookmarks.ts (+6 -3)
📝 packages/trpc/routers/tags.test.ts (+34 -0)

📄 Description

Summary

Fixes #1317 — typing #tag, ##tag, or even ###tag could save a double‑hash tag to the database, breaking search.
We now trim whitespace and strip every leading # on every tag‑creation path:

  • standalone Tags screen (tags.create, tags.update)
  • bookmark editor (bookmarks.updateTags)

UI continues to display #tag; only storage is normalized.

Key changes

packages/trpc/utils/tag.ts: new normalizeTagName helper
packages/trpc/routers/tags.ts: call helper in create and conditional update
packages/trpc/routers/bookmarks.ts: apply helper (bulk) + ignore empty names to avoid values() must be called with at least one value error
packages/trpc/routers/tags.test.ts: +2 tests (create & update) confirming hashes are stripped

Tests

pnpx vitest run packages/trpc

  • All existing suites pass.
  • New cases:
    • ##demo → stored demo (create)
    • rename #foo##bar → stored bar (update)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/karakeep-app/karakeep/pull/1351 **Author:** [@mostafa-wahied](https://github.com/mostafa-wahied) **Created:** 5/3/2025 **Status:** ✅ Merged **Merged:** 6/22/2025 **Merged by:** [@MohamedBassem](https://github.com/MohamedBassem) **Base:** `main` ← **Head:** `fix/normalize-tag-leading-hash-1317` --- ### 📝 Commits (4) - [`c95d349`](https://github.com/karakeep-app/karakeep/commit/c95d3499d3c2476d3b3c381e42f03a3f00659e16) fix(tags): normalise leading hashes in tag names (#1317) - [`fc81658`](https://github.com/karakeep-app/karakeep/commit/fc81658cd10b28f497e54e9ffad155509816da00) Merge branch 'main' into fix/normalize-tag-leading-hash-1317 - [`887569a`](https://github.com/karakeep-app/karakeep/commit/887569acd36440373b11467899f21cb9a9a0a0c7) move the transformation to zod - [`6404268`](https://github.com/karakeep-app/karakeep/commit/6404268d8d841366d6bbc06745ec3eae91fbb4fd) fix openapi spec ### 📊 Changes **5 files changed** (+56 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `packages/open-api/karakeep-openapi-spec.json` (+1 -2) 📝 `packages/shared/types/tags.ts` (+9 -2) ➕ `packages/shared/utils/tag.ts` (+6 -0) 📝 `packages/trpc/routers/bookmarks.ts` (+6 -3) 📝 `packages/trpc/routers/tags.test.ts` (+34 -0) </details> ### 📄 Description ## Summary Fixes #1317 — typing `#tag`, `##tag`, or even `###tag` could save a double‑hash tag to the database, breaking search. We now trim whitespace and strip every leading `#` on every tag‑creation path: - standalone Tags screen (`tags.create`, `tags.update`) - bookmark editor (`bookmarks.updateTags`) UI continues to display #tag; only storage is normalized. ## Key changes `packages/trpc/utils/tag.ts`: new `normalizeTagName` helper `packages/trpc/routers/tags.ts`: call helper in create and conditional update `packages/trpc/routers/bookmarks.ts`: apply helper (bulk) + ignore empty names to avoid `values() must be called with at least one value` error `packages/trpc/routers/tags.test.ts`: +2 tests (create & update) confirming hashes are stripped ## Tests `pnpx vitest run packages/trpc` - All existing suites pass. - New cases: - `##demo` → stored `demo` (create) - rename `#foo`→`##bar` → stored `bar` (update) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-02 11:59:16 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/karakeep#1806
No description provided.