Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: npm package "urllib": invalid type: map, expected a string #23862

Closed
iugo opened this issue May 17, 2024 · 6 comments · Fixed by #23868
Closed

fix: npm package "urllib": invalid type: map, expected a string #23862

iugo opened this issue May 17, 2024 · 6 comments · Fixed by #23868
Labels
bug Something isn't working

Comments

@iugo
Copy link
Contributor

iugo commented May 17, 2024

Version: Deno 1.43.4

There is a file named test.ts with the following content:

import urllib from 'npm:urllib@2.41.0';

console.log(urllib);

An error occurred when executing the command deno check -r test.ts:

error: Error getting response at https://registry.npmjs.org/urllib for package "urllib": invalid type: map, expected a string at line 1 column 24565
    at file:///Users/.../test.ts:1:20

This issue was not present in Deno 1.43.3 according to the actual test.

@hugojosefson
Copy link

🙋 The same with npm:joi:

import joi from "npm:joi@17.13.1";

console.log(joi);

Works with Deno version 1.43.3.

Fails with Deno version 1.43.4:

error: Error getting response at https://registry.npmjs.org/joi for package "joi": invalid type: map, expected a string at line 1 column 18384
    at file:///test.ts:1:17

The url https://registry.npmjs.org/joi, does indeed return json that, at the position given in the error message, contains a run-script value that isn't a string, but a json object. It was present in the ancient joi@0.1.0, removed in the almost as ancient joi@0.2.1.

🫚 Root cause?

I suspect this newly found insensitivity to incorrect package.json run-scripts, was brought in by this entry in the deno 1.43.4 changelog:

fix(npm): handle null fields in npm registry JSON (#23785)

Following that update, leads to this commit in deno_npm:

denoland/deno_npm@0.20.0...0.20.1#diff-d5b93d4a7caa06c359c97e5e8528a0b6c636621edba60a960f3f5afeed0c97a8R171

That's how far my understanding goes! I'm not familiar enough with serde in rust to know what the previous default behaviour was, that was apparently overridden here. In general though, for npm compatibility, we might want to be more lenient to parts of json from older versions of modules that we don't even need to use?

@bartlomieju
Copy link
Member

CC @dsherret can you take a look? Seems like a regression.

@bartlomieju bartlomieju added the bug Something isn't working label May 17, 2024
@dsherret
Copy link
Member

I think this was caused by denoland/deno_npm#47

@bartlomieju
Copy link
Member

bartlomieju commented May 17, 2024

It looks so, here's the problematic bit:

"scripts": {
    "test": "make test && make test-cov",
    "blanket": {
        "pattern": "//^((?!/node_modules/)(?!/test/).)*$/ig",
        "onlyCwd": true,
        "data-cover-flags": {
            "branchTracking": true
        }
    },
    "travis-cov": {
        "threshold": 100
    }
},

I'll open a PR to deno_npm later today.

@dsherret
Copy link
Member

This is now fixed in Deno 1.43.5

@hugojosefson
Copy link

Thank you so much @dsherret and @bartlomieju!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants