[BUG] npm audit signatures shows an opaque JSON error when the registry returns a non-JSON attestations response

Đang mở
#10,368 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

@Fariiixm đang làm issue này rồi.

Từ ngày 27/11/2026.

  • #10369 của @Fariiixm — đang mở

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript, node.js
Lĩnh vực
cli, security

Hướng nghiên cứu

Start by tracing the npm audit signatures command's attestations response handling and the fetch error path that produces the JSON parse message; the issue does not name specific files or tests. Check existing tests for invalid attestations responses and add coverage for a non-JSON response that identifies the package and registry problem. Done when the message is clear while verification still fails closed.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Bug Needs Triage
Is there an existing issue for this?
  • I have searched the existing issues
This issue exists in the latest npm version
  • I am using the latest npm
This is not just a request to bump a dependency for a CVE
  • This is not solely a request to bump a dependency for a CVE
Current Behavior

When the attestations endpoint returns a non-JSON body (here a CDN-cached text/plain "OK"), npm audit signatures fails with:

npm error code FETCH_ERROR
npm error invalid json response body at https://registry.npmjs.org/-/npm/v1/attestations/@typescript-eslint%[email protected] reason: Unexpected token 'O', "OK
" is not valid JSON

The message does not say that the registry served a bad response or what the user can do. It took header-level debugging (comparing CDN edges) to find out it was a registry-side cache problem: https://github.com/orgs/community/discussions/214163

Expected Behavior

A clear error that names the package and says the registry returned an invalid attestations response, for example:

npm error Could not verify attestations for @typescript-eslint/[email protected]: the registry returned an invalid response (content-type text/plain). This is usually a temporary registry problem; check https://status.npmjs.org or retry later.

Verification should still fail closed. Only the message needs to change.

Steps To Reproduce

From a client routed to the Cloudflare MAD edge (which currently serves a cached text/plain "OK" for this attestations URL):

mkdir repro && cd repro && npm init -y
npm install @typescript-eslint/[email protected] --ignore-scripts
npm audit signatures

Result:

npm error code FETCH_ERROR
npm error invalid json response body at https://registry.npmjs.org/-/npm/v1/attestations/@typescript-eslint%[email protected] reason: Unexpected token 'O', "OK
" is not valid JSON
Environment
  • npm: 12.2.3 (also reproduced with 12.2.2)
  • Node.js: 24 (node:24-alpine)
  • OS Name: Alpine Linux (CI container)
  • System Model Name: CI runner (Docker executor)
  • npm config: defaults (reproduced in an empty project)
Ngôn ngữ chính
JavaScript
Star
10.3k
Fork
5k
Merge trung bình
4 ngày 11 giờ
Pull request đã merge (30 ngày)
26

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của npm/cli

Tất cả issue của npm/cli

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.