glideapps / quicktype

Generate types and converters from JSON, Schema, and GraphQL
https://app.quicktype.io
Apache License 2.0
11.77k stars 1.04k forks source link

[BUG]: http error is unhandled and empty content is returned #2572

Open nam-truong-le opened 2 months ago

nam-truong-le commented 2 months ago

At this location https://github.com/glideapps/quicktype/blob/master/packages/quicktype-core/src/input/io/NodeIO.ts#L43 we should check the HTTP response code.

Issue Type

Reading file from URL

Context (Environment, Version, Language)

N/A

Input Format: Output Language:

N/A

CLI, npm, or app.quicktype.io: Version:

Description

For example, when I provide a github token like this in the cli --http-header "Authorization: token $GITHUB_TOKEN" and the token is expired, instead of throwing an error, quicktype generate empty content.

Input Data

Expected Behaviour / Output

The process should fail

Current Behaviour / Output

quicktype generates empty content.

Steps to Reproduce

Use an expired github token to access github raw URL.

Possible Solution

Check HTTP response code.