Skip to content

fix(api): tolerate missing related users in memo conversions#5809

Merged
boojack merged 1 commit intomainfrom
listmemos
Apr 6, 2026
Merged

fix(api): tolerate missing related users in memo conversions#5809
boojack merged 1 commit intomainfrom
listmemos

Conversation

@boojack
Copy link
Copy Markdown
Member

@boojack boojack commented Apr 6, 2026

Summary

  • batch-load reaction creators during memo conversion and skip orphaned reactions instead of failing the whole response
  • skip memos and memo comments with missing creators in list flows while preserving NotFound behavior for direct lookups and shared memo access
  • skip notifications with missing sender or receiver users to prevent a single bad record from breaking the list API
  • add regression tests for orphaned memo creators, reaction creators, comment creators, and notification users

Testing

  • go test ./server/router/api/v1/test

Summary by CodeRabbit

  • Bug Fixes

    • Improved error handling when user creators are deleted; list operations now gracefully skip orphaned memos, comments, reactions, and notifications instead of failing entirely.
    • Updated sharing endpoints to return proper "not found" responses when memo creators are missing.
  • Tests

    • Added comprehensive test coverage for scenarios where related user creators have been deleted.

@boojack boojack requested a review from a team as a code owner April 6, 2026 00:19
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 6, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

The PR introduces graceful degradation for missing creators across memo, reaction, comment, and notification entities. Instead of failing requests entirely, services now log warnings, skip orphaned entities, and return successfully with remaining valid data. This includes refactoring batch user-loading logic to minimize database queries when resolving creators.

Changes

Cohort / File(s) Summary
Memo Service Core Logic
server/router/api/v1/memo_service.go, server/router/api/v1/memo_service_converter.go
Added sentinel errors for missing creators (errMemoCreatorNotFound, errReactionCreatorNotFound). Refactored conversion pipeline to batch-load users via listUsersByIDWithExisting, skip orphaned reactions/memos with a warning log instead of failing, and delegate reaction conversion to new convertReactionsFromStoreWithCreators helper.
Dependent Service Updates
server/router/api/v1/memo_share_service.go, server/router/api/v1/reaction_service.go, server/router/api/v1/user_service.go
Updated error handling to detect missing-creator sentinel errors and return gRPC NotFound status (memo_share_service) or skip with warning logs (reaction_service, user_service) instead of propagating conversion errors.
Integration Tests
server/router/api/v1/test/memo_service_test.go, server/router/api/v1/test/memo_share_service_test.go, server/router/api/v1/test/reaction_service_test.go, server/router/api/v1/test/user_notification_test.go
Added comprehensive test coverage for graceful handling of deleted creators: reactions, memos, comments, and notifications with missing creators are now omitted from responses rather than causing request failures.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 Hops through deleted users with grace,
No more crashing at a missing face,
Warn and skip, let data flow free,
A resilient memo service, huzzah!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely summarizes the main change: refactoring the API to handle missing related users gracefully during memo conversions by skipping orphaned entities instead of failing.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch listmemos

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@boojack boojack merged commit 25feef3 into main Apr 6, 2026
5 of 6 checks passed
@boojack boojack deleted the listmemos branch April 6, 2026 00:23
dgalanberasaluce pushed a commit to dgalanberasaluce/infra-personal that referenced this pull request Apr 27, 2026
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [neosmemo/memos](https://github.com/usememos/memos) | minor | `0.26.2` → `0.27.1` |

---

### Release Notes

<details>
<summary>usememos/memos (neosmemo/memos)</summary>

### [`v0.27.1`](https://github.com/usememos/memos/blob/HEAD/CHANGELOG.md#0271-2026-04-19)

[Compare Source](usememos/memos@v0.27.0...v0.27.1)

##### Bug Fixes

- mixed-case user resource names ([#&#8203;5853](usememos/memos#5853)) ([01be01f](usememos/memos@01be01f))
- **release:** inject build version into artifacts ([f8a304b](usememos/memos@f8a304b))
- user resource names can be uuidv4 from idp sub claim ([#&#8203;5856](usememos/memos#5856)) ([bbded58](usememos/memos@bbded58))

### [`v0.27.0`](https://github.com/usememos/memos/blob/HEAD/CHANGELOG.md#0270-2026-04-18)

[Compare Source](usememos/memos@v0.26.2...v0.27.0)

##### Features

- add --allow-private-webhooks flag to bypass SSRF protection ([#&#8203;5694](usememos/memos#5694)) ([cd5816c](usememos/memos@cd5816c))
- add blur\_content attribute to tag metadata settings ([#&#8203;5767](usememos/memos#5767)) ([45b2153](usememos/memos@45b2153))
- add Gemini transcription provider ([#&#8203;5830](usememos/memos#5830)) ([d87539a](usememos/memos@d87539a))
- add GitHub release installer and release workflow ([1ed542c](usememos/memos@1ed542c))
- add live refresh via Server-Sent Events (SSE) with visual indicator ([#&#8203;5638](usememos/memos#5638)) ([ea0892a](usememos/memos@ea0892a))
- add MCP server with PAT authentication ([47d9414](usememos/memos@47d9414))
- add outline navigation to memo detail sidebar ([#&#8203;5771](usememos/memos#5771)) ([6b30579](usememos/memos@6b30579))
- **ai:** add BYOK audio transcription ([#&#8203;5832](usememos/memos#5832)) ([101704c](usememos/memos@101704c))
- **ai:** add instance AI providers and transcription ([#&#8203;5829](usememos/memos#5829)) ([83ed32f](usememos/memos@83ed32f))
- **attachments:** add Live Photo and Motion Photo support ([#&#8203;5810](usememos/memos#5810)) ([4b4e719](usememos/memos@4b4e719))
- **cli:** add version subcommand ([#&#8203;5731](usememos/memos#5731)) ([0ba4c0f](usememos/memos@0ba4c0f))
- **editor:** add voice note recording to the memo composer ([#&#8203;5801](usememos/memos#5801)) ([c0d5854](usememos/memos@c0d5854))
- extract title from first H1 heading into memo property ([#&#8203;5726](usememos/memos#5726)) ([1e688b2](usememos/memos@1e688b2))
- **i18n:** update sse connect label in Chinese ([#&#8203;5732](usememos/memos#5732)) ([89c6902](usememos/memos@89c6902))
- **instance:** add canonical tag metadata setting ([#&#8203;5736](usememos/memos#5736)) ([65d14fb](usememos/memos@65d14fb))
- **instance:** add notification transport setting ([#&#8203;5737](usememos/memos#5737)) ([a249d06](usememos/memos@a249d06))
- **mcp:** enhance MCP server with full capabilities and new tools ([#&#8203;5720](usememos/memos#5720)) ([b8e9ee2](usememos/memos@b8e9ee2))
- **mcp:** harden tool exposure and side effects ([#&#8203;5850](usememos/memos#5850)) ([583c3d2](usememos/memos@583c3d2))
- **mcp:** refactor MCP server to standard protocol structure ([803d488](usememos/memos@803d488))
- **memo-editor:** add compact live waveform recorder panel ([#&#8203;5817](usememos/memos#5817)) ([e51985a](usememos/memos@e51985a))
- **memo-preview:** support comment metadata in previews ([#&#8203;5768](usememos/memos#5768)) ([e176b28](usememos/memos@e176b28))
- **memo:** add image sharing in detail view ([38fc22b](usememos/memos@38fc22b))
- **memo:** add share links for private memos ([#&#8203;5742](usememos/memos#5742)) ([3f3133d](usememos/memos@3f3133d))
- **mentions:** add memo mention parsing, notifications, and rendering ([#&#8203;5811](usememos/memos#5811)) ([24fc8ab](usememos/memos@24fc8ab))
- replace auto-increment ID with UID for identity provider resource names ([#&#8203;5687](usememos/memos#5687)) ([92d937b](usememos/memos@92d937b))
- show inline comment preview in list view ([3a5d3c8](usememos/memos@3a5d3c8))
- **store:** change default storage type to local filesystem ([78efa68](usememos/memos@78efa68))
- treat tag setting keys as anchored regex patterns ([#&#8203;5759](usememos/memos#5759)) ([9e04049](usememos/memos@9e04049))
- **ui:** allow navigating between images with arrows in preview dialog  ([#&#8203;5669](usememos/memos#5669)) ([104d2ec](usememos/memos@104d2ec))
- **user:** add per-user tag metadata settings ([#&#8203;5735](usememos/memos#5735)) ([330291d](usememos/memos@330291d))
- **web:** add demo mode banner ([#&#8203;5836](usememos/memos#5836)) ([35504cc](usememos/memos@35504cc))
- **webhook:** dispatch webhook on memo comment creation ([7c1defb](usememos/memos@7c1defb))

##### Bug Fixes

- access token refresh on web app ([#&#8203;5681](usememos/memos#5681)) ([3010f10](usememos/memos@3010f10))
- add unix socket file permission setting (755 -> 660) ([#&#8203;5849](usememos/memos#5849)) ([0fc1dab](usememos/memos@0fc1dab))
- **api:** appease image size lint ([ff6389a](usememos/memos@ff6389a))
- **api:** improve SSE hub design and fix double-broadcast on comments ([c53677f](usememos/memos@c53677f))
- **api:** make credentials write-only and restrict sensitive settings to admins ([9d3a74b](usememos/memos@9d3a74b))
- **api:** reduce memory pressure in backend paths ([c456637](usememos/memos@c456637))
- **api:** remove public activity service ([#&#8203;5734](usememos/memos#5734)) ([04f239a](usememos/memos@04f239a))
- **api:** restrict user email exposure to self and admins ([#&#8203;5784](usememos/memos#5784)) ([a24d420](usememos/memos@a24d420))
- **api:** switch user resource names to usernames ([#&#8203;5779](usememos/memos#5779)) ([acddef1](usememos/memos@acddef1))
- **api:** tolerate missing related users in memo conversions ([#&#8203;5809](usememos/memos#5809)) ([25feef3](usememos/memos@25feef3))
- **auth:** recover session via refresh cookie when localStorage is empty ([#&#8203;5748](usememos/memos#5748)) ([551ee1d](usememos/memos@551ee1d))
- backend tests action ([065e817](usememos/memos@065e817))
- clear content search filter when selecting shortcut ([#&#8203;5499](usememos/memos#5499)) ([2c3f9e3](usememos/memos@2c3f9e3))
- correct typos in comments, error messages, and identifiers ([#&#8203;5704](usememos/memos#5704)) ([8f43e80](usememos/memos@8f43e80))
- detect legacy installations with empty schema version ([9628d3d](usememos/memos@9628d3d))
- **editor:** show newly linked memos when editing a memo with attachments ([026ea92](usememos/memos@026ea92))
- ensure comment divs span full width in MemoDetail ([ce44164](usememos/memos@ce44164))
- **fileserver:** render SVG attachment previews ([40fd700](usememos/memos@40fd700))
- **filter:** enforce CEL syntax semantics ([0e89407](usememos/memos@0e89407))
- **frontend:** restore sitemap and robots routes ([fee7fcd](usememos/memos@fee7fcd))
- handle chunk load errors after redeployment with auto-reload ([#&#8203;5703](usememos/memos#5703)) ([bdd3554](usememos/memos@bdd3554))
- harden memo content iframe and HTML sanitization ([7e21b72](usememos/memos@7e21b72))
- hide transcribe button without AI provider ([ab53329](usememos/memos@ab53329))
- improve image preview dialog and live photo trigger ([aafcc21](usememos/memos@aafcc21))
- improve installer compatibility and docs ([f90d9a4](usememos/memos@f90d9a4))
- improve KaTeX and Mermaid error handling and overflow ([6b37fcc](usememos/memos@6b37fcc))
- include plain URLs and tags in memo snippet generation ([#&#8203;5688](usememos/memos#5688)) ([3d4f793](usememos/memos@3d4f793))
- **lint:** correct goimports struct literal alignment after removing write-only credential fields ([#&#8203;5794](usememos/memos#5794)) ([9610ed8](usememos/memos@9610ed8))
- **map:** align dark mode map styling ([7ac9989](usememos/memos@7ac9989))
- **map:** refine Leaflet controls and memo map styling ([894b3eb](usememos/memos@894b3eb))
- **markdown:** support height/width attributes on img elements ([737acbb](usememos/memos@737acbb))
- **memo-editor:** scope Cmd+Enter save to the active editor ([#&#8203;5745](usememos/memos#5745)) ([05810e7](usememos/memos@05810e7))
- **mysql:** handle CreateMemo custom timestamps with FROM\_UNIXTIME ([#&#8203;5673](usememos/memos#5673)) ([09d73e8](usememos/memos@09d73e8))
- normalize attachment MIME types before validation ([c3e7e2c](usememos/memos@c3e7e2c))
- preserve draft content when tab is suspended or editor remounts ([9ca7122](usememos/memos@9ca7122))
- prevent local attachment uploads from overwriting files ([4add9b0](usememos/memos@4add9b0))
- prevent stale comment drafts from being restored ([e520b63](usememos/memos@e520b63))
- remove duplicate Japanese locale keys ([efeb28c](usememos/memos@efeb28c))
- render audio attachments as inline players ([#&#8203;5699](usememos/memos#5699)) ([2ccb98a](usememos/memos@2ccb98a))
- restrict archived memo access to creator only ([#&#8203;5707](usememos/memos#5707)) ([f4154d0](usememos/memos@f4154d0))
- **routing:** redirect unauthenticated users to /explore when public visibility is allowed ([98859eb](usememos/memos@98859eb))
- **server:** close SSE clients during shutdown ([a5ddd5a](usememos/memos@a5ddd5a))
- sync html lang attribute with active locale ([#&#8203;5753](usememos/memos#5753)) ([be00abe](usememos/memos@be00abe))
- tag parsing truncates emojis with variation selectors ([#&#8203;5496](usememos/memos#5496)) ([3ea6ea3](usememos/memos@3ea6ea3))
- **tags:** allow blur-only tag metadata ([#&#8203;5800](usememos/memos#5800)) ([1921b57](usememos/memos@1921b57))
- toggle focus mode do not reset editor height ([#&#8203;5504](usememos/memos#5504)) ([0729779](usememos/memos@0729779))
- **ui:** show comment editor above the comment list ([#&#8203;5662](usememos/memos#5662)) ([6b0736b](usememos/memos@6b0736b))
- **ui:** unify metadata component styles across MemoView and MemoEditor ([664b8c5](usememos/memos@664b8c5))
- unify live photo previews around LIVE badge playback ([6b0487d](usememos/memos@6b0487d))
- **webhooks:** trigger memo updates for attachment and relation changes ([#&#8203;5795](usememos/memos#5795)) ([acbc914](usememos/memos@acbc914))
- **web:** prevent MemoContent prop leaks ([22519b5](usememos/memos@22519b5))
- **web:** refine attachment media layout ([a0d83e1](usememos/memos@a0d83e1))
- **web:** refresh memo detail cache after editor save ([333c9df](usememos/memos@333c9df))
- **web:** use BroadcastChannel to sync token refreshes across tabs ([bbdc998](usememos/memos@bbdc998))

##### Performance Improvements

- batch load memo relations when listing memos ([#&#8203;5692](usememos/memos#5692)) ([1e82714](usememos/memos@1e82714))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My43My4yIiwidXBkYXRlZEluVmVyIjoiNDMuNzMuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsicmVub3ZhdGUiXX0=-->

Reviewed-on: https://forgejo.internal/forgejo_admin/infra-personal/pulls/75
Co-authored-by: Renovate Bot <renovatebot@forgejo.internal>
Co-committed-by: Renovate Bot <renovatebot@forgejo.internal>
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.

1 participant