Skip to content

fix: preserve merged headers in repository-meta fetch options (spread order bug) #2765

@coderabbitai

Description

@coderabbitai

Summary

In shared/utils/repository-meta.ts, the object spread order when building fetch options causes ...options to overwrite the entire headers object, discarding the merged User-Agent: npmx header (and any other headers built up prior to the spread).

This is a pre-existing issue that originated in app/composables/useRepoMeta.ts on main and was moved as-is into the new shared utility in #2764.

Problem

The current pattern (at 8 locations) is:

// Incorrect — outer ...options clobbers the headers object
{ headers: { 'User-Agent': 'npmx', ...options.headers }, ...options }

Fix

Spread options first, then override headers with the merged value:

// Correct — User-Agent preserved, caller headers merged in
{ ...options, headers: { 'User-Agent': 'npmx', ...options.headers } }

Affected locations

  • shared/utils/repository-meta.ts lines 118, 160, 197, 236, 275, 321, 422, 466

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions