Fix parse_lpo_and_dwpp not raising ValueError when disable_web_page_preview=False#5268
Merged
harshil21 merged 3 commits intoJun 17, 2026
Conversation
When disable_web_page_preview=False (explicitly enabling previews) was
passed alongside link_preview_options, the mutual-exclusivity guard:
if disable_web_page_preview and link_preview_options:
evaluated to False (short-circuit), so no ValueError was raised.
Instead, the user's link_preview_options was silently overwritten with
LinkPreviewOptions(is_disabled=False), discarding their value.
Fix: use 'is not None' to check for any explicit non-None value.
Regression: add the False case to test_mutually_exclusive.
harshil21
reviewed
Jun 17, 2026
harshil21
left a comment
Member
There was a problem hiding this comment.
Thanks for the very subtle bug catch. This didn't have any bad effects since None-ness is still falsy, so it worked just fine. But yes, it's important to have correctness.
Contributor
Author
|
Thanks @harshil21 — applied your suggestion; the chango fragment now uses double backticks for all identifiers. |
harshil21
approved these changes
Jun 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
parse_lpo_and_dwppis documented to raiseValueErrorwhen bothdisable_web_page_previewandlink_preview_optionsare supplied(they are mutually exclusive). However, when
disable_web_page_preview=Falsethe guard used a truthy check:
False and Xshort-circuits toFalse, so noValueErroris raised.The code then falls through to the second condition:
which silently overwrites the caller's
link_preview_optionswithLinkPreviewOptions(is_disabled=False), discarding the user-supplied value.Fix
Change the guard to
is not Noneso any explicitboolvalue triggers themutual-exclusivity check:
Verification
Before fix:
test_mutually_exclusivepasses only theTruesub-case; the newFalsesub-case fails (ValueErroris not raised).After fix: all 7 tests in the file pass.