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

Value mismatch for the option level #21426

Closed
bdabelow opened this issue Sep 17, 2024 · 10 comments
Closed

Value mismatch for the option level #21426

bdabelow opened this issue Sep 17, 2024 · 10 comments
Assignees
Labels

Comments

@bdabelow
Copy link
Contributor

bdabelow commented Sep 17, 2024

Describe the bug
Running pants with -l=debug (or apparently any value other than info) causes:

08:22:29.52 [WARN] Found differences between the new native options parser and the legacy options parser in scope [GLOBAL]:

- Value mismatch for the option `level`:
    Legacy value: LogLevel.INFO of type <enum 'LogLevel'>, from source HARDCODED
    Native value: LogLevel.DEBUG of type <enum 'LogLevel'>, from source FLAG

I have used pants -l=debug help global to reproduce, but also happens with other commands. The error does not occur when using the long form --level=<value>

Pants version
Can reproduce with 2.22.0 and 2.23.0a0.

OS
Linux

@bdabelow bdabelow added the bug label Sep 17, 2024
@benjyw benjyw self-assigned this Sep 18, 2024
@benjyw
Copy link
Contributor

benjyw commented Sep 18, 2024

Thanks for the report, I'll take a look asap.

@benjyw
Copy link
Contributor

benjyw commented Sep 18, 2024

Interestingly, this happens only when using an = sign: -l=debug. -ldebug doesn't give a discrepancy.

In fact I'm mildly surprised that -l=debug even works. Short flags were not intended to take an equals sign.

@benjyw
Copy link
Contributor

benjyw commented Sep 18, 2024

This seems like a bug in the discrepancy calculator, since the discrepancy is:

- Value mismatch for the option `level`:
    Legacy value: LogLevel.INFO of type <enum 'LogLevel'>, from source HARDCODED
    Native value: LogLevel.DEBUG of type <enum 'LogLevel'>, from source FLAG

But we are seeing the debug output, so the legacy value used in practice is not actually INFO but DEBUG. I will take a closer look.

@bdabelow
Copy link
Contributor Author

bdabelow commented Sep 18, 2024

As a side remark, pants help is showing the short option with equals sign:
image

@benjyw
Copy link
Contributor

benjyw commented Sep 18, 2024

Ha, OK, I see what's going on. So, -l=debug is not supported in the legacy parser (I'm not sure why it doesn't error), but is supported in the native parser. It so happens that log levels are consumed and applied by pantsd, which is written in Rust, so we still see debug logging (if we add --no-pantsd then we no longer get debug logging with -l=debug).

@benjyw
Copy link
Contributor

benjyw commented Sep 18, 2024

As a side remark, pants help is showing the short option with equals sign

Well that's just adding insult to injury... :(

@benjyw
Copy link
Contributor

benjyw commented Sep 18, 2024

I am reluctant to change the behavior of the legacy parser at this late stage, since it's about to be deleted in 2.24.x, and I fear ripple effects and inadvertent breakage.

Is using -ldebug an acceptable workaround? It would just be for 2.22.x and 2.23.x, since, as mentioned, this will all work on the native parser alone in 2.24.x.

@bdabelow
Copy link
Contributor Author

bdabelow commented Sep 18, 2024

Is using -ldebug an acceptable workaround? It would just be for 2.22.x and 2.23.x, since, as mentioned, this will all work on the native parser alone in 2.24.x.

Sure, this works for me.

Is the help output also generated by the parser and will be fixed once the switch to the native parser is completed? Or should I create a separate issue for that?

Or should help remain as is, as short options with equals sign will be supported with the native parser IIUC.

@benjyw
Copy link
Contributor

benjyw commented Sep 18, 2024

I think an issue for that would be good, thanks. It is true that it will work with an equals sign, but it's not how short options are intended to be used, so it's probably preferable for the help output to say the right thing...

@benjyw
Copy link
Contributor

benjyw commented Sep 18, 2024

Will close this one, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants