-
Notifications
You must be signed in to change notification settings - Fork 27.9k
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
json schema parsing should not complain about UTF-8 BOM in schemas #163683
Comments
Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.72.2. Please try upgrading to the latest version and checking whether this issue remains. Happy Coding! |
It still repros on the latest. And by the way, you can repro the problem yourself with this JSON file: {
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/dc0a8cfe732e7e589836225666b81e1b7ef58d82/src/NerdBank.GitVersioning/version.schema.json",
"version": "1.0"
} |
See https://www.rfc-editor.org/rfc/rfc8259#section-8.1
I assume that can be applied when stored in files. |
I can remove or reword the warning if you have pointers to specs that clarify that. From what I've seen many consumers of JSON struggle with it, so I think the warning is useful. |
Thank you for responding quickly and for the RFC link. It makes sense that JSON shouldn't include the BOM when it's network transmitted. Such cases like HTTP include headers that already identify the encoding anyway. |
I'm not aware of such a feature. In VS Code you can define the encoding to be used for by default for writing files: files.encoding, but we always persist the encoding. So ok to close this issue? I think issuing the warning when loading the schema from a URL is proper. |
@aeschli This issue presents a case where assuming the input strictly adheres to this section of the JSON specification is causing a problem for some users. In addition, the JSON specification explicitly allows a JSON processor (e.g. VS Code) to accept input in this form in order to avoid causing this pain for users. I believe it would be net-beneficial to update VS Code accordingly, even if the input is not supposed to be in this form.
Note that we don't necessarily need to remove this warning from the current JSON document during editing, but for the case of JSON Schema the user is not actively editing the schema and just wants to get work done. I'm specifically requesting the BOM be ignored in the linked schema file. |
What you see is just a warning (not an error). We just ignore the BOM and and continue to process the schema. |
Type: Bug
The JSON editor supports the
$schema
property, which is great. And although it apparently works when those schemas start with a UTF-8 BOM, it complains when doing so.UTF-8 BOM at the beginning of files is not a defect. Please remove the warning about not supporting them (and continue to actually work when they are present).
VS Code version: Code 1.72.1 (129500e, 2022-10-10T17:22:48.346Z)
OS version: Windows_NT x64 10.0.22621
Modes:
Sandboxed: No
System Info
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: disabled_software
multiple_raster_threads: enabled_on
opengl: disabled_off
rasterization: disabled_software
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: disabled_software
video_encode: disabled_software
vulkan: disabled_off
webgl: unavailable_software
webgl2: unavailable_software
webgpu: disabled_off
Extensions (68)
(1 theme extensions excluded)
A/B Experiments
The text was updated successfully, but these errors were encountered: