Skip to content

fix: use owners.name facet for user profile pkgs#2513

Merged
43081j merged 1 commit intonpmx-dev:mainfrom
jonchurch:fix/algolia-filter-on-owners-name
Apr 14, 2026
Merged

fix: use owners.name facet for user profile pkgs#2513
43081j merged 1 commit intonpmx-dev:mainfrom
jonchurch:fix/algolia-filter-on-owners-name

Conversation

@jonchurch
Copy link
Copy Markdown
Contributor

@jonchurch jonchurch commented Apr 14, 2026

🔗 Linked issue

closes #2504

🧭 Context

The profiles for users was querying against an Algolia field which represented repo owner, not npm username. That meant that the packages being displayed on profiles were only tangentially related to said npm username, or completely unrelated.

Once algolia/npm-search#1357 landed upstream at the algolia index, it opened us up to filter on a field which represents an npm user.

This PR switches to that field.

After this PR, user profile pages will return all packages that an npm user is listed as a maintainer on. This will still include deprecated packages, just like it did previously (whcih was not a bug, just the nature of the data source being used and no filtering, there's some issue about it but that's out of scope here)

Note: there's no concept of an "owner" that npm exposes publicly that Im aware of. the best you can do is check if a user is in the maintainer's array. That's a detail that's not really important here as the previous logic hinged on that fact anyways despite querying on bad information. I updated the name of the function used here to align with the reality of the npm field we are checking.

Before 📸

any package whos repository field in package.json has the same username as the npm user will show up on the user's page, even if said user is not a maintainer/owner of said package
Screenshot 2026-04-14 at 5 56 18 AM

and any packages a user maintains which are not in a repo of the same username are omitted
Screenshot 2026-04-14 at 5 43 37 AM

After 📸

no more spoofing possible!
Screenshot 2026-04-14 at 5 56 06 AM

now all packages that an npm user is a maintainer of will be displayed on their profile (express is now accounted for in my profile, hence the download stat change)
Screenshot 2026-04-14 at 5 43 20 AM

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Apr 14, 2026 10:10am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Apr 14, 2026 10:10am
npmx-lunaria Ignored Ignored Apr 14, 2026 10:10am

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 14, 2026

📝 Walkthrough

Summary by CodeRabbit

Release Notes

  • Refactor
    • Updated the package search filtering mechanism to use refined maintainer identification logic, enhancing consistency in package discovery queries.

Walkthrough

Renamed and re-exported the maintainer-targeted search helper and switched Algolia owner filters to use owners.name:. Updated callers to use the new searchByMaintainer export; no other control flow or response mapping changes.

Changes

Cohort / File(s) Summary
Algolia composable
app/composables/npm/useAlgoliaSearch.ts
Renamed internal/exported helper from searchByOwnersearchByMaintainer; replaced Algolia filter owner.name:${...}owners.name:${...} in the maintainer pagination query and in the user-existence subquery within searchWithSuggestions(); export changed accordingly.
User packages consumer
app/composables/npm/useUserPackages.ts
Updated consumer to call searchByMaintainer(user) instead of searchByOwner(user) for provider === 'algolia'; no other logic altered.

Possibly related PRs

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and specifically describes the main change: switching from owner.name to owners.name facet for user profile packages query.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, explaining the problem, root cause, upstream fix, and providing before/after screenshots demonstrating the fix.
Linked Issues check ✅ Passed The PR fully addresses the linked issue #2504 by implementing the upstream fix approach: changing Algolia filter from owner.name to owners.name and renaming the helper function from searchByOwner to searchByMaintainer to reflect npm maintainership semantics.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the linked issue requirements: updating filter fields and function names in two files related to user package query logic.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@jonchurch jonchurch force-pushed the fix/algolia-filter-on-owners-name branch from 6739d56 to 7296731 Compare April 14, 2026 10:00
Copy link
Copy Markdown
Contributor

@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.

🧹 Nitpick comments (1)
app/composables/npm/useAlgoliaSearch.ts (1)

164-165: Update the JSDoc to match the new facet name.

Line 164 still mentions owner.name, but the implementation now uses owners.name. Keeping the comment in sync will avoid confusion during maintenance.

Suggested doc fix
-  /** Fetch all packages for an owner using `owner.name` filter with pagination. */
+  /** Fetch all packages for an owner using `owners.name` filter with pagination. */
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/composables/npm/useAlgoliaSearch.ts` around lines 164 - 165, Update the
JSDoc for the async function searchByOwner to reference the correct facet name
"owners.name" instead of the outdated "owner.name"; locate the comment above the
function searchByOwner in useAlgoliaSearch.ts and change any mention of
owner.name to owners.name so the documentation matches the current
implementation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@app/composables/npm/useAlgoliaSearch.ts`:
- Around line 164-165: Update the JSDoc for the async function searchByOwner to
reference the correct facet name "owners.name" instead of the outdated
"owner.name"; locate the comment above the function searchByOwner in
useAlgoliaSearch.ts and change any mention of owner.name to owners.name so the
documentation matches the current implementation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ff059c65-ab55-4a03-aa06-79426e4c38d3

📥 Commits

Reviewing files that changed from the base of the PR and between 8b57e4e and 6739d56.

📒 Files selected for processing (1)
  • app/composables/npm/useAlgoliaSearch.ts

Copy link
Copy Markdown
Contributor

@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.

🧹 Nitpick comments (2)
app/composables/npm/useUserPackages.ts (1)

31-31: Update stale JSDoc wording to match the new filter semantics.

The composable comment still mentions owner.name; it should now reference maintainer-based filtering (owners.name) to avoid confusion for future edits.

As per coding guidelines: "Add comments only to explain complex logic or non-obvious implementations".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/composables/npm/useUserPackages.ts` at line 31, The JSDoc above the
composable still refers to outdated owner.name semantics; update the comment for
the composable containing useUserPackages and the reference to
searchByMaintainer to describe maintainer-based filtering and the correct
property name owners.name (or “owners.name” in examples) so it matches the new
filter behavior and avoids confusion for future edits.
app/composables/npm/useAlgoliaSearch.ts (1)

165-167: Consider renaming ownerName to maintainerName for API clarity.

The function name and filter target maintainers, so aligning the parameter name would make intent clearer.

♻️ Proposed tidy-up
 async function searchByMaintainer(
-  ownerName: string,
+  maintainerName: string,
   options: { maxResults?: number } = {},
 ): Promise<NpmSearchResponse> {
@@
-            filters: `owners.name:${ownerName}`,
+            filters: `owners.name:${maintainerName}`,

As per coding guidelines: "Use clear, descriptive variable and function names".

Also applies to: 188-188

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/composables/npm/useAlgoliaSearch.ts` around lines 165 - 167, Rename the
parameter ownerName to maintainerName in the searchByMaintainer function
signature and its internal usages (function searchByMaintainer and any
references within that function), update all call sites and related references
(also the occurrence around the other mention at the same file) to use
maintainerName, and keep the options param unchanged; ensure TypeScript types
and JSDoc (if any) are updated accordingly to avoid type errors.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@app/composables/npm/useAlgoliaSearch.ts`:
- Around line 165-167: Rename the parameter ownerName to maintainerName in the
searchByMaintainer function signature and its internal usages (function
searchByMaintainer and any references within that function), update all call
sites and related references (also the occurrence around the other mention at
the same file) to use maintainerName, and keep the options param unchanged;
ensure TypeScript types and JSDoc (if any) are updated accordingly to avoid type
errors.

In `@app/composables/npm/useUserPackages.ts`:
- Line 31: The JSDoc above the composable still refers to outdated owner.name
semantics; update the comment for the composable containing useUserPackages and
the reference to searchByMaintainer to describe maintainer-based filtering and
the correct property name owners.name (or “owners.name” in examples) so it
matches the new filter behavior and avoids confusion for future edits.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7a1f27ee-cde7-4508-8502-4ef427fdff7b

📥 Commits

Reviewing files that changed from the base of the PR and between 7296731 and 8a9258e.

📒 Files selected for processing (2)
  • app/composables/npm/useAlgoliaSearch.ts
  • app/composables/npm/useUserPackages.ts

@43081j 43081j added this pull request to the merge queue Apr 14, 2026
Merged via the queue into npmx-dev:main with commit 5efdff9 Apr 14, 2026
22 checks passed
@github-actions github-actions bot mentioned this pull request Apr 14, 2026
@jonchurch jonchurch deleted the fix/algolia-filter-on-owners-name branch April 14, 2026 18:46
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.

~user profile pages show packages by repo owner, not npm maintainer

2 participants