fix: validate secondary_link URL when value is present#895
Closed
ashsolei wants to merge 1 commit intohesreallyhim:mainfrom
Closed
fix: validate secondary_link URL when value is present#895ashsolei wants to merge 1 commit intohesreallyhim:mainfrom
ashsolei wants to merge 1 commit intohesreallyhim:mainfrom
Conversation
The URL validation loop skipped secondary_link entirely due to an overly broad exclusion (`field != "secondary_link"`). This meant a secondary_link containing spaces or missing the https:// scheme would pass validation silently. Change the condition so that empty optional fields are skipped (via `continue`), but non-empty values are always validated regardless of which field they belong to. The required-field check earlier in the function already ensures primary_link and author_link are present.
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes URL validation in validate_parsed_data() so secondary_link is validated when present (while still allowing it to be empty), aligning behavior with the intent of “optional but must be valid if provided”.
Changes:
- Replace the
field != "secondary_link"exclusion with an early-continue for empty values. - Ensure all non-empty URL fields (
primary_link,secondary_link,author_link) are validated forhttps://prefix and spaces.
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.
Problem
The URL validation loop in
parse_issue_form.pyskipssecondary_linkentirely:This means a
secondary_linkcontaining spaces or missing thehttps://scheme passes validation silently. The intent was to make the field optional (no error when empty), but the implementation also skips validation when a value IS provided.Fix
Replace the field-name exclusion with an early
continueon empty values:Non-empty values are now validated regardless of which field they belong to. The required-field check earlier in
validate_parsed_data()already ensuresprimary_linkandauthor_linkare present, so skipping empty optional fields is safe.1 file changed, 6 insertions, 5 deletions. All 314 tests pass.