Skip to content

Conversation

@jelle-openai
Copy link
Contributor

Summary

Fixes #19922.

The approach I used is to check the required-version separately before parsing the TOML. This feels a bit ugly because we have to parse the TOML separately, but other approaches I considered seemed worse:

  • Put the version validation inside SerDe deserialization for RequiredVersion. But this feels wrong: a required version that doesn't match the current version should still parse. Also, I think this means the user might see more errors than just the one for the version mismatch, when ideally they should only see the version mismatch error.
  • Rewrite Options to be much more lenient in parsing everything else (in particular, don't validate rule names). However, this would be a bigger rewrite, and might still cause issues similar to Validate required_version before validating rules #19922 if e.g. a new field is added.

Test Plan

New test cases added.

@MichaReiser MichaReiser added the configuration Related to settings and configuration label Jan 6, 2026
@MichaReiser
Copy link
Member

Nice

@astral-sh-bot
Copy link

astral-sh-bot bot commented Jan 6, 2026

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@MichaReiser
Copy link
Member

MichaReiser commented Jan 6, 2026

Hmm, the ecosystem changes are a bit surprising. Can you try rebasing on main?

@jelle-openai
Copy link
Contributor Author

Hm do those changes mean it found more autofixes? That would be weird.

I'll apply your suggested change and merge in with latest main.

Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. This is great and nice find with DeTable.

I only have a question whether we need the required_version fallback and if we retain the spans in error messages if the required version fails to parse.

Comment on lines 148 to 149
let required_version = RequiredVersion::try_from(required_version.to_string())
.with_context(|| format!("Failed to parse {}", path.display()))?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect that we lose the span in the error message compared to when deserializing the value as part of the serde deserialization. I'm inclined to return Ok here and defer to the "full" deserialization in that case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a test for this case too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You were right, changed it as you suggested.

@MichaReiser MichaReiser enabled auto-merge (squash) January 7, 2026 17:01
@MichaReiser MichaReiser merged commit c02d164 into astral-sh:main Jan 7, 2026
39 checks passed
@jelle-openai jelle-openai deleted the fix-19922 branch January 7, 2026 17:51
@jelle-openai
Copy link
Contributor Author

Thanks for the review and merge @MichaReiser!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

configuration Related to settings and configuration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validate required_version before validating rules

2 participants