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

restore: cargo.toml #4544

Closed
wants to merge 2 commits into from

Conversation

yassun7010
Copy link
Contributor

Copy link
Contributor

Thanks for the PR!

This section of the codebase is owned by @yassun7010 - if they write a comment saying "LGTM" then it will be merged.

@dandedotdev
Copy link

dandedotdev commented Mar 11, 2025

Thank you for making this PR. However, I ran into some issues this afternoon.

Here are some contents in my Cargo.toml (these settings could be found in The Cargo Book)

[profile.dev]
codegen-units = 1
debug = 2
debug-assertions = true
incremental = true
opt-level = 2
overflow-checks = true

And I use the schema here, which is:

#:schema https://raw.githubusercontent.com/SchemaStore/schemastore/542d8d8efe76b1e38d2d7d3a4a0237636c379c47/src/schemas/json/cargo.json

Error messages of my CI taplo-lint below:

^ Additional properties are not allowed ('codegen-units', 'debug', 'debug-assertions', 'incremental', 'opt-level', 'overflow-checks' were unexpected)

Thank you for your time and attention!

@hyperupcall
Copy link
Member

I merged #4546 that fully reverted #4540 (comment)

@hyperupcall
Copy link
Member

hyperupcall commented Mar 11, 2025

@yassun7010 I would strongly advice against changing additionalProperties, even if is possibly correct. There is just too high a change that the error is due to an omission of properties in the schema, rather than the inclusion of a bad property.

Though I understand the need for showing errors in this case, I just think by default there will be too many false positives. Just thinking out loud here, what if Tombi had a "strict" mode for Schema errors? In that case, it would "automatically set" additionalProperties to false. That way, by default, most users won't see false positives errors. And those that do set it, know what they are getting themselves into, and will be able to see more errors (including ones from incomplete schemas). To opt out, maybe this "strict mode" won't be evaluated on an object with additionalProperties: true.

@yassun7010
Copy link
Contributor Author

@hyperupcall
Thanks for picking up on this.

I had to work and did not have time to respond.

I will accepts the strict mode suggestion.

JSON Schema is a loose specification,
When the schema for Cargo.toml was created, additionalProperties were not considerd.

There are probably many other similar schemas.

Thanks 👍

@yassun7010 yassun7010 closed this Mar 11, 2025
@panekj
Copy link

panekj commented Mar 11, 2025

Sorry, I hadn't much time to look into this but is there something from taplo side that could be improved? From the brief look into schema I haven't noticed any properties that weren't defined (but I also looked only via github diff UI which is terrible)

@yassun7010
Copy link
Contributor Author

@panekj

After investigation, it is not a taplo problem.

There was an actual case where a property (e.g. profile.dev.strip) was not defined in the JSON Schema of Cargo.toml, resulting in an error.

This can be handled on the JSON Schema side.

If there are improvements to be made on the taplo side, how about making errors only for properties that are not allowed, instead of listing the names of allowed properties in the error message?

The GitHub diff of the JSON Schema for Cargo.toml has changed at the request of Tombi.

Tombi has a setting “x-tombi-table-keys-order”: “schema” that reorders the keys in the order defined in “properties”, so the order in “properties” is sorted from ascending alphabetical order.

@yassun7010
Copy link
Contributor Author

fix and update [profile] schema.

#4549

@yassun7010 yassun7010 mentioned this pull request Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants