Skip to content

feat: add route to fetch user by jellyfin id#2074

Open
fredrikburmester wants to merge 4 commits intoseerr-team:developfrom
fredrikburmester:develop
Open

feat: add route to fetch user by jellyfin id#2074
fredrikburmester wants to merge 4 commits intoseerr-team:developfrom
fredrikburmester:develop

Conversation

@fredrikburmester
Copy link
Copy Markdown

@fredrikburmester fredrikburmester commented Oct 19, 2025

Description

Fetch a seerr user by Jellyfin ID. Currently this is not possible and from my understanding makes it difficult for clients to find a user without fetching all users and matching the ID.

How Has This Been Tested?

Not tested.

Screenshots / Logs (if applicable)

Checklist:

  • I have read and followed the contribution guidelines.
  • Disclosed any use of AI (see our policy)
  • I have updated the documentation accordingly.
  • All new and existing tests passed.
  • Successful build pnpm build
  • Translation keys pnpm i18n:extract
  • Database migration (if required)

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • New endpoint to retrieve user information by Jellyfin ID with permission-based filtering of returned data.
    • Returns 404 when no matching user is found.
    • Returns 400 for invalid Jellyfin ID formats.

@fredrikburmester fredrikburmester requested a review from a team as a code owner October 19, 2025 19:09
@0xSysR3ll
Copy link
Copy Markdown
Contributor

You will also need to update the API's documentation to make this work.

@fredrikburmester
Copy link
Copy Markdown
Author

Thank you I'll do that.

@fredrikburmester
Copy link
Copy Markdown
Author

Added ✅ @0xSysR3ll

One question though. The user/{userId} endpoint says: "[...] Requires the MANAGE_USERS permission.". This seems inaccurate since it only filters the JSON based on permissions, not block the endpoint completely (401/403). Now, I use the same permissions as that endpoint, but i think it's more accurate to write "[...] Returns filtered data based on the caller's permissions."

Am I misunderstanding how permissions are handled, or is it fine as I've written it?

@gauthier-th
Copy link
Copy Markdown
Member

Am I misunderstanding how permissions are handled, or is it fine as I've written it?

It's fine like you wrote it, the description from the user/{userId} endpoint is not accurate, it is indeed filtered based on the user permission.

gauthier-th
gauthier-th previously approved these changes Oct 20, 2025
0xSysR3ll
0xSysR3ll previously approved these changes Oct 20, 2025
Comment thread server/routes/user/index.ts
@github-actions
Copy link
Copy Markdown

This PR is stale because it has been open 30 days with no activity. Please address the feedback or provide an update to keep it open.

@github-actions github-actions Bot added the stale label Jan 14, 2026
@fallenbagel
Copy link
Copy Markdown
Collaborator

@fredrikburmester are you able to work on this pr or should we take over?

@fallenbagel fallenbagel removed the stale label Jan 14, 2026
@fredrikburmester
Copy link
Copy Markdown
Author

Sorry i totally forgot about fixing the formatting issue. I can get to it tonight but if you have time, feel free to fix and merge.

@github-actions
Copy link
Copy Markdown

This PR is stale because it has been open 30 days with no activity. Please address the feedback or provide an update to keep it open.

@github-actions github-actions Bot added the stale label Feb 14, 2026
@github-actions
Copy link
Copy Markdown

This PR was closed because it has been stalled for 30 days with no activity. You can reopen it once you address the feedback or provide the requested changes.

@github-actions github-actions Bot closed this Mar 16, 2026
@fallenbagel fallenbagel reopened this Mar 16, 2026
@Gauvino
Copy link
Copy Markdown
Contributor

Gauvino commented Mar 16, 2026

anything missing from this pr to get review ?

@gauthier-th
Copy link
Copy Markdown
Member

anything missing from this pr to get review ?

#2074 (comment)

@0xSysR3ll
Copy link
Copy Markdown
Contributor

anything missing from this pr to get review ?

#2074 (comment)
And rebase

@github-actions github-actions Bot removed the stale label Mar 17, 2026
@fallenbagel fallenbagel added this to the v3.2.0 milestone Mar 28, 2026
@fallenbagel fallenbagel dismissed gauthier-th’s stale review March 28, 2026 19:37

Dismissing till requested changes are resolved

@seerr-automation-bot seerr-automation-bot removed this from the v3.2.0 milestone Mar 28, 2026
@github-actions
Copy link
Copy Markdown

This PR is stale because it has been open 30 days with no activity. Please address the feedback or provide an update to keep it open.

@github-actions github-actions Bot added the stale label Apr 28, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

📝 Walkthrough

Walkthrough

A new API endpoint is added to retrieve a user by their Jellyfin ID via GET /user/jellyfin/{jellyfinUserId}. The endpoint includes OpenAPI documentation and implementation with permission-based response filtering and 404 error handling for missing users.

Changes

Cohort / File(s) Summary
User Jellyfin Lookup Endpoint
seerr-api.yml, server/routes/user/index.ts
New GET /user/jellyfin/{jellyfinUserId} endpoint added to the OpenAPI spec and implemented in routes. Validates/normalizes Jellyfin GUID, returns User JSON schema on 200, maps missing user to 404, and applies permission-based filtering to the returned user payload.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • gauthier-th
  • fallenbagel

Poem

🐰 I sniffed a Jellyfin GUID in the grass,
Followed its trail through routes and past,
A check, a filter, a tidy 200 cheer,
If not found — a gentle 404 appears.
Hooray — another endpoint hops near! ✨

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add route to fetch user by jellyfin id' clearly and specifically describes the main change in the pull request, which adds a new API endpoint to retrieve users by Jellyfin ID.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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


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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@server/routes/user/index.ts`:
- Around line 429-431: The DB lookup uses the raw path param
req.params.jellyfinUserId which can cause false 404s for equivalent IDs with
different casing/whitespace/formatting; before calling
userRepository.findOneOrFail, normalize the incoming ID (e.g., trim(),
toLowerCase(), and any Jellyfin-specific canonicalization such as removing
surrounding braces or prefixes) into a variable (e.g., normalizedJellyfinId) and
use that variable in the where clause instead of req.params.jellyfinUserId so
lookups match stored normalized IDs in the User entity.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d20a7055-2406-4e8a-97e0-4cf67771c953

📥 Commits

Reviewing files that changed from the base of the PR and between d50bdad and 3d3784c.

📒 Files selected for processing (2)
  • seerr-api.yml
  • server/routes/user/index.ts

Comment thread server/routes/user/index.ts
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
server/routes/user/index.ts (1)

429-436: ⚠️ Potential issue | 🟠 Major

Support both raw and normalized Jellyfin IDs during lookup.

At Line 434, the query only uses the normalized ID. Because existing records can still contain non-normalized jellyfinUserId values, this can return false 404s. Query both raw and normalized forms (or backfill normalized IDs) for compatibility.

Suggested patch
-      const jellyfinUserId = normalizeJellyfinGuid(req.params.jellyfinUserId);
+      const rawJellyfinUserId = req.params.jellyfinUserId;
+      const jellyfinUserId = normalizeJellyfinGuid(rawJellyfinUserId);
       if (!jellyfinUserId) {
         return next({ status: 400, message: 'Invalid Jellyfin User ID.' });
       }

       const user = await userRepository.findOneOrFail({
-        where: { jellyfinUserId },
+        where: [
+          { jellyfinUserId },
+          { jellyfinUserId: rawJellyfinUserId },
+        ],
       });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@server/routes/user/index.ts` around lines 429 - 436, The lookup uses only the
normalized ID (jellyfinUserId) so existing records with raw IDs may be missed;
modify the retrieval logic around normalizeJellyfinGuid and
userRepository.findOneOrFail to query for either the normalized value or the
original req.params.jellyfinUserId (e.g., use a WHERE with OR on jellyfinUserId
or two-step lookup: try findOneOrFail by normalized ID then fallback to the raw
ID) while keeping normalizeJellyfinGuid, jellyfinUserId,
req.params.jellyfinUserId and userRepository.findOneOrFail as the referenced
symbols.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@server/routes/user/index.ts`:
- Around line 429-436: The lookup uses only the normalized ID (jellyfinUserId)
so existing records with raw IDs may be missed; modify the retrieval logic
around normalizeJellyfinGuid and userRepository.findOneOrFail to query for
either the normalized value or the original req.params.jellyfinUserId (e.g., use
a WHERE with OR on jellyfinUserId or two-step lookup: try findOneOrFail by
normalized ID then fallback to the raw ID) while keeping normalizeJellyfinGuid,
jellyfinUserId, req.params.jellyfinUserId and userRepository.findOneOrFail as
the referenced symbols.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e0c7df79-eef3-4752-a24a-c29fb50f0e27

📥 Commits

Reviewing files that changed from the base of the PR and between 3d3784c and feb9b9e.

📒 Files selected for processing (1)
  • server/routes/user/index.ts

@github-actions github-actions Bot removed the stale label Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants