cli icon indicating copy to clipboard operation
cli copied to clipboard

I really don't know

Open pschaeffer opened this issue 11 months ago • 6 comments

Describe the bug

I was told to report this. See below.

Please report this problem at https://ntl.fyi/cli-error including the error details below.

URIError: URI malformed at decodeURIComponent () at rewriter (file:///C:/Users/Peter/AppData/Roaming/npm/node_modules/netlify-cli/dist/utils/rules-proxy.js:90:19) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async onRequest (file:///C:/Users/Peter/AppData/Roaming/npm/node_modules/netlify-cli/dist/utils/proxy.js:623:19)

System: OS: Windows 10 10.0.19045 CPU: (8) x64 Intel(R) Core(TM) i7-4702HQ CPU @ 2.20GHz Binaries: Node: 20.9.0 - C:\Program Files (x86)\nodejs\node.EXE npm: 10.1.0 - C:\Program Files (x86)\nodejs\npm.CMD Browsers: Edge: Chromium (122.0.2365.92)

Steps to reproduce

I entered 'netlify dev' (without the quotes)

Configuration

System: OS: Windows 10 10.0.19045 CPU: (8) x64 Intel(R) Core(TM) i7-4702HQ CPU @ 2.20GHz Binaries: Node: 20.9.0 - C:\Program Files (x86)\nodejs\node.EXE npm: 10.1.0 - C:\Program Files (x86)\nodejs\npm.CMD Browsers: Edge: Chromium (122.0.2365.92)

Environment

System: OS: Windows 10 10.0.19045 CPU: (8) x64 Intel(R) Core(TM) i7-4702HQ CPU @ 2.20GHz Memory: 6.21 GB / 15.91 GB Binaries: Node: 20.9.0 - C:\Program Files (x86)\nodejs\node.EXE Yarn: 1.22.21 - ~\Documents\Visual_Studio_Code\Projects\WebApplication5\WebApplication5\node_modules.bin\yarn.CMD npm: 9.9.2 - ~\Documents\Visual_Studio_Code\Projects\WebApplication5\WebApplication5\node_modules.bin\npm.CMD

pschaeffer avatar Mar 17 '24 03:03 pschaeffer

I have some more details on this 'bug'. I am not sure (either way) if this is really a Netlify bug or not. The error is occurring in a decodeURICompont() call in rules-proxy.js. What is interesting is that decodeURIComponent is being invoked on 'bad' data. However, I don't know if the code should have even made it that far. I have many more details, if you need them.

pschaeffer avatar Mar 17 '24 19:03 pschaeffer

Hi Peter! What version of the Netlify CLI are you using? Also, could you provide a minimal reproduction repo, that I can use to look at this on my machine?

Skn0tt avatar Mar 26 '24 13:03 Skn0tt

Hi Simon Knott,

I really don’t know what version of the Netlify CLI I am using. Probably the latest. I did enter a few commands to get an answer. See below.

PS C:\Users\Peter\Documents\Visual_Studio_Code\Projects\WebApplication5\WebApplication5\my-remix-udemy-section3-netlify4> npx envinfo --system --binaries --npmPackages netlify-cli --npmGlobalPackages netlify-cli

System:

OS: Windows 10 10.0.19045

CPU: (8) x64 Intel(R) Core(TM) i7-4702HQ CPU @ 2.20GHz

Memory: 6.60 GB / 15.91 GB

Binaries:

Node: 20.9.0 - C:\Program Files (x86)\nodejs\node.EXE

Yarn: 1.22.21 - ~\Documents\Visual_Studio_Code\Projects\WebApplication5\WebApplication5\node_modules\.bin\yarn.CMD

npm: 9.9.2 - ~\Documents\Visual_Studio_Code\Projects\WebApplication5\WebApplication5\node_modules\.bin\npm.CMD

PS C:\Users\Peter\Documents\Visual_Studio_Code\Projects\WebApplication5\WebApplication5\my-remix-udemy-section3-netlify4> netlify --version

netlify-cli/17.19.4 win32-x64 node-v20.9.0

PS C:\Users\Peter\Documents\Visual_Studio_Code\Projects\WebApplication5\WebApplication5\my-remix-udemy-section3-netlify4>

Is the answer 17.19.4? Not sure.

Thank you

Peter Schaeffer

P.S. Also see Netlify Forums number 114610 and 114611.

P.S.S. Please note that I am having two separate problems with Netlify. Netlify (all lower case really) serve fails for a really minimal application. Netlify (all lower case really) dev fails for a much more complex application. I think you are more interested in the second problem. Take a look at https://github.com/pschaeffer/my-remix-udemy-section3-netlify3 for a public repo. However, I don’t think this repo is going to help you much. The ‘problem’ is in rules-proxy.js (I put problem is quotes because this may not be a Netlify problem at all). See below for a section of rules-proxy.js (with my temporary fix).

};

};

// @ts-expect-error TS(7006) FIXME: Parameter 'req' implicitly has an 'any' type.

return async function rewriter(req) {

    const matcherFunc = await getMatcher();

    const reqUrl = new URL(req.url, `${req.protocol || (req.headers.scheme && `${req.headers.scheme}:`) || 'http:'}//${req.hostname || req.headers.host}`);

    const cookieValues = cookie.parse(req.headers.cookie || '');

    const headers = {

        'x-language': cookieValues.nf_lang || getLanguage(req.headers),

        'x-country': cookieValues.nf_country || geoCountry || 'us',

        ...req.headers,

    };

    // Definition: https://github.com/netlify/libredirect/blob/e81bbeeff9f7c260a5fb74cad296ccc67a92325b/node/src/redirects.cpp#L28-L60

    let decodedPath = '';

    try {

      decodedPath = decodeURIComponent(reqUrl.pathname);

            }

            catch (decodedPathError) {

              console.log('In rules-proxy', reqUrl.pathname);

              console.log(decodedPathError);

            }

    const matchReq = {

        scheme: reqUrl.protocol.replace(/:.*$/, ''),

        host: reqUrl.hostname,

        path: decodedPath,

        query: reqUrl.search.slice(1),

        headers,

        cookieValues,

        // @ts-expect-error TS(7006) FIXME: Parameter 'name' implicitly has an 'any' type.

        getHeader: (name) => headers[name.toLowerCase()] || '',

        // @ts-expect-error TS(7006) FIXME: Parameter 'key' implicitly has an 'any' type.

        getCookie: (key) => cookieValues[key] || '',

    };

    const match = matcherFunc.match(matchReq);

    return match;

};

};

The Visual Studio Code log (part of the log) follows.

➜ Local: http://localhost:5173/

➜ Network: use --host to expose

✔ Waiting for framework port 5173. This can be configured using the 'targetPort' property in the netlify.toml

┌─────────────────────────────────────────────────┐

│ │

│ ◈ Server now ready on http://localhost:8888 │

│ │

└─────────────────────────────────────────────────┘

In rules-proxy /.marketing-section%20%7B%20%20margin:%206rem%20auto;%7D.marketing-section%20header%20%7B%20%20display:%20flex;%20%20gap:%202rem;%20%20align-items:%20center;%20%20color:%20var(--color-primary-50);%7D.marketing-section:last-of-type%20%7B%20%20text-align:%20right;%7D.marketing-section:last-of-type%20header%20%7B%20%20justify-content:%20flex-end;%7D.marketing-section%20svg%20%7B%20%20font-size:%201.25rem;%7D.marketing-section%20h2%20%7B%20%20margin:%200;%7D.marketing-content%20%7B%20%20display:%20flex;%20%20gap:%202rem;%20%20margin:%203rem%200;%7D.marketing-image%20%7B%20%20width:%2050%;%20%20border-radius:%208px;%20%20box-shadow:%200%202px%208px%20rgba(0,%200,%200,%200.2);%20%20padding:%200.5rem;%20%20background-color:%20var(--color-primary-100);%20%20display:%20flex;%20%20justify-content:%20center;%20%20align-items:%20center;%20%20transform:%20rotateZ(-5deg);%7D.marketing-image:last-child%20%7B%20%20transform:%20rotateZ(5deg);%7D.marketing-image%20img%20%7B%20%20width:%20100%;%20%20border-radius:%204px;%7D.marketing-explanation%20%7B%20%20width:%2050%;%7D

URIError: URI malformed

at decodeURIComponent (<anonymous>)

at rewriter (file:///C:/Users/Peter/AppData/Roaming/npm/node_modules/netlify-cli/dist/utils/rules-proxy.js:89:25)

at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

at async onRequest (file:///C:/Users/Peter/AppData/Roaming/npm/node_modules/netlify-cli/dist/utils/proxy.js:623:19)

11:46:11 AM [vite] Internal server error: URI malformed

  at decodeURI (<anonymous>)

  at viteTransformMiddleware (file:///C:/Users/Peter/Documents/Visual_Studio_Code/Projects/WebApplication5/WebApplication5/my-remix-udemy-section3-netlify3/node_modules/vite/dist/node/chunks/dep-stQc5rCc.js:63291:19)

  at call (file:///C:/Users/Peter/Documents/Visual_Studio_Code/Projects/WebApplication5/WebApplication5/my-remix-udemy-section3-netlify3/node_modules/vite/dist/node/chunks/dep-stQc5rCc.js:42646:7)

  at next (file:///C:/Users/Peter/Documents/Visual_Studio_Code/Projects/WebApplication5/WebApplication5/my-remix-udemy-section3-netlify3/node_modules/vite/dist/node/chunks/dep-stQc5rCc.js:42590:5)

From: Simon Knott @.> Sent: Tuesday, March 26, 2024 8:37 AM To: netlify/cli @.> Cc: Peter Schaeffer @.>; Author @.> Subject: Re: [netlify/cli] I really don't know (Issue #6448)

Hi Peter! What version of the Netlify CLI are you using? Also, could you provide a minimal reproduction repo, that I can use to look at this on my machine?

— Reply to this email directly, view it on GitHub https://github.com/netlify/cli/issues/6448#issuecomment-2020452940 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AA4LSSW6XUOA4TTB5KAE3CTY2FTYTAVCNFSM6AAAAABEZ2XXRKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRQGQ2TEOJUGA . You are receiving this because you authored the thread. https://github.com/notifications/beacon/AA4LSSQHDFKZBGCWJP6WMGDY2FTYTA5CNFSM6AAAAABEZ2XXRKWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTYNWVEY.gif Message ID: @.*** @.***> >

pschaeffer avatar Mar 26 '24 17:03 pschaeffer

Hi Simon Knott,

I can provide any additional information you need to resolve the problems.

As I see there are two (to me, quite different) Netlify-Remix problems.

  1. Netlify serve (actually all lowercase) fails for an empty configuration, with an invalid import.
  2. Netlify dev (actually all lowercase) fails for relatively complex configuration with a decodeURIComponent error.

Thank you

Peter Schaeffer

P.S. To get the second error, I had to install (at least) .prisma, @prisma, bcryptjs, and react-icons. I also had to make sure the environmental variables were set. I set the environmental variable by restarting Visual Studio Code. Note that my-remix-udemy-section3-netlify3 repo is missing the node_modules directory.

From: @.*** @.> Sent: Tuesday, March 26, 2024 12:43 PM To: 'netlify/cli' @.>; 'netlify/cli' @.> Cc: 'Author' @.> Subject: RE: [netlify/cli] I really don't know (Issue #6448)

Hi Simon Knott,

I really don’t know what version of the Netlify CLI I am using. Probably the latest. I did enter a few commands to get an answer. See below.

PS C:\Users\Peter\Documents\Visual_Studio_Code\Projects\WebApplication5\WebApplication5\my-remix-udemy-section3-netlify4> npx envinfo --system --binaries --npmPackages netlify-cli --npmGlobalPackages netlify-cli

System:

OS: Windows 10 10.0.19045

CPU: (8) x64 Intel(R) Core(TM) i7-4702HQ CPU @ 2.20GHz

Memory: 6.60 GB / 15.91 GB

Binaries:

Node: 20.9.0 - C:\Program Files (x86)\nodejs\node.EXE

Yarn: 1.22.21 - ~\Documents\Visual_Studio_Code\Projects\WebApplication5\WebApplication5\node_modules\.bin\yarn.CMD

npm: 9.9.2 - ~\Documents\Visual_Studio_Code\Projects\WebApplication5\WebApplication5\node_modules\.bin\npm.CMD

PS C:\Users\Peter\Documents\Visual_Studio_Code\Projects\WebApplication5\WebApplication5\my-remix-udemy-section3-netlify4> netlify --version

netlify-cli/17.19.4 win32-x64 node-v20.9.0

PS C:\Users\Peter\Documents\Visual_Studio_Code\Projects\WebApplication5\WebApplication5\my-remix-udemy-section3-netlify4>

Is the answer 17.19.4? Not sure.

Thank you

Peter Schaeffer

P.S. Also see Netlify Forums number 114610 and 114611.

P.S.S. Please note that I am having two separate problems with Netlify. Netlify (all lower case really) serve fails for a really minimal application. Netlify (all lower case really) dev fails for a much more complex application. I think you are more interested in the second problem. Take a look at https://github.com/pschaeffer/my-remix-udemy-section3-netlify3 for a public repo. However, I don’t think this repo is going to help you much. The ‘problem’ is in rules-proxy.js (I put problem is quotes because this may not be a Netlify problem at all). See below for a section of rules-proxy.js (with my temporary fix).

};

};

// @ts-expect-error TS(7006) FIXME: Parameter 'req' implicitly has an 'any' type.

return async function rewriter(req) {

    const matcherFunc = await getMatcher();

    const reqUrl = new URL(req.url, `${req.protocol || (req.headers.scheme && `${req.headers.scheme}:`) || 'http:'}//${req.hostname || req.headers.host}`);

    const cookieValues = cookie.parse(req.headers.cookie || '');

    const headers = {

        'x-language': cookieValues.nf_lang || getLanguage(req.headers),

        'x-country': cookieValues.nf_country || geoCountry || 'us',

        ...req.headers,

    };

    // Definition: https://github.com/netlify/libredirect/blob/e81bbeeff9f7c260a5fb74cad296ccc67a92325b/node/src/redirects.cpp#L28-L60

    let decodedPath = '';

    try {

      decodedPath = decodeURIComponent(reqUrl.pathname);

            }

            catch (decodedPathError) {

              console.log('In rules-proxy', reqUrl.pathname);

              console.log(decodedPathError);

            }

    const matchReq = {

        scheme: reqUrl.protocol.replace(/:.*$/, ''),

        host: reqUrl.hostname,

        path: decodedPath,

        query: reqUrl.search.slice(1),

        headers,

        cookieValues,

        // @ts-expect-error TS(7006) FIXME: Parameter 'name' implicitly has an 'any' type.

        getHeader: (name) => headers[name.toLowerCase()] || '',

        // @ts-expect-error TS(7006) FIXME: Parameter 'key' implicitly has an 'any' type.

        getCookie: (key) => cookieValues[key] || '',

    };

    const match = matcherFunc.match(matchReq);

    return match;

};

};

The Visual Studio Code log (part of the log) follows.

➜ Local: http://localhost:5173/

➜ Network: use --host to expose

✔ Waiting for framework port 5173. This can be configured using the 'targetPort' property in the netlify.toml

┌─────────────────────────────────────────────────┐

│ │

│ ◈ Server now ready on http://localhost:8888 │

│ │

└─────────────────────────────────────────────────┘

In rules-proxy /.marketing-section%20%7B%20%20margin:%206rem%20auto;%7D.marketing-section%20header%20%7B%20%20display:%20flex;%20%20gap:%202rem;%20%20align-items:%20center;%20%20color:%20var(--color-primary-50);%7D.marketing-section:last-of-type%20%7B%20%20text-align:%20right;%7D.marketing-section:last-of-type%20header%20%7B%20%20justify-content:%20flex-end;%7D.marketing-section%20svg%20%7B%20%20font-size:%201.25rem;%7D.marketing-section%20h2%20%7B%20%20margin:%200;%7D.marketing-content%20%7B%20%20display:%20flex;%20%20gap:%202rem;%20%20margin:%203rem%200;%7D.marketing-image%20%7B%20%20width:%2050%;%20%20border-radius:%208px;%20%20box-shadow:%200%202px%208px%20rgba(0,%200,%200,%200.2);%20%20padding:%200.5rem;%20%20background-color:%20var(--color-primary-100);%20%20display:%20flex;%20%20justify-content:%20center;%20%20align-items:%20center;%20%20transform:%20rotateZ(-5deg);%7D.marketing-image:last-child%20%7B%20%20transform:%20rotateZ(5deg);%7D.marketing-image%20img%20%7B%20%20width:%20100%;%20%20border-radius:%204px;%7D.marketing-explanation%20%7B%20%20width:%2050%;%7D

URIError: URI malformed

at decodeURIComponent (<anonymous>)

at rewriter (file:///C:/Users/Peter/AppData/Roaming/npm/node_modules/netlify-cli/dist/utils/rules-proxy.js:89:25)

at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

at async onRequest (file:///C:/Users/Peter/AppData/Roaming/npm/node_modules/netlify-cli/dist/utils/proxy.js:623:19)

11:46:11 AM [vite] Internal server error: URI malformed

  at decodeURI (<anonymous>)

  at viteTransformMiddleware (file:///C:/Users/Peter/Documents/Visual_Studio_Code/Projects/WebApplication5/WebApplication5/my-remix-udemy-section3-netlify3/node_modules/vite/dist/node/chunks/dep-stQc5rCc.js:63291:19)

  at call (file:///C:/Users/Peter/Documents/Visual_Studio_Code/Projects/WebApplication5/WebApplication5/my-remix-udemy-section3-netlify3/node_modules/vite/dist/node/chunks/dep-stQc5rCc.js:42646:7)

  at next (file:///C:/Users/Peter/Documents/Visual_Studio_Code/Projects/WebApplication5/WebApplication5/my-remix-udemy-section3-netlify3/node_modules/vite/dist/node/chunks/dep-stQc5rCc.js:42590:5)

From: Simon Knott @.*** @.> > Sent: Tuesday, March 26, 2024 8:37 AM To: netlify/cli @. @.> > Cc: Peter Schaeffer @. @.> >; Author @. @.***> > Subject: Re: [netlify/cli] I really don't know (Issue #6448)

Hi Peter! What version of the Netlify CLI are you using? Also, could you provide a minimal reproduction repo, that I can use to look at this on my machine?

— Reply to this email directly, view it on GitHub https://github.com/netlify/cli/issues/6448#issuecomment-2020452940 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AA4LSSW6XUOA4TTB5KAE3CTY2FTYTAVCNFSM6AAAAABEZ2XXRKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRQGQ2TEOJUGA . You are receiving this because you authored the thread. https://github.com/notifications/beacon/AA4LSSQHDFKZBGCWJP6WMGDY2FTYTA5CNFSM6AAAAABEZ2XXRKWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTYNWVEY.gif Message ID: @.*** @.***> >

pschaeffer avatar Mar 27 '24 05:03 pschaeffer

https://github.com/pschaeffer/my-remix-udemy-section3-netlify3 gives me an error when running npm run build. I can't reproduce the error you're reporting based on that. I'd be happy help here, but I really need a minimal reproduction case.

Skn0tt avatar Mar 27 '24 12:03 Skn0tt

Hi Simon Knott,

I also got errors when I ran ‘npm run build’. I fixed the ‘npm run build’ errors. The online repo has the fixes.

However, ‘npm run build’ is not part of the steps Netlify suggests. See the README.md file in the repo. The README.md file say that I should run ‘netlify dev’ (with no quotes) after I ran ‘npm install’ (which I did).

Thank you

Peter Schaeffer

From: Simon Knott @.> Sent: Wednesday, March 27, 2024 7:54 AM To: netlify/cli @.> Cc: Peter Schaeffer @.>; Author @.> Subject: Re: [netlify/cli] I really don't know (Issue #6448)

https://github.com/pschaeffer/my-remix-udemy-section3-netlify3 gives me an error when running npm run build. I can't reproduce the error you're reporting based on that. I'd be happy help here, but I really need a minimal reproduction case.

— Reply to this email directly, view it on GitHub https://github.com/netlify/cli/issues/6448#issuecomment-2022697030 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AA4LSSWMHGR6Z6M7QCQUZTLY2KXM7AVCNFSM6AAAAABEZ2XXRKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRSGY4TOMBTGA . You are receiving this because you authored the thread. https://github.com/notifications/beacon/AA4LSSTCOQQJSTWR3OARKLTY2KXM7A5CNFSM6AAAAABEZ2XXRKWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTYR7UEM.gif Message ID: @.*** @.***> >

pschaeffer avatar Mar 27 '24 20:03 pschaeffer