Skip to content

fix: validate secondary_link URL when value is present#895

Closed
ashsolei wants to merge 1 commit intohesreallyhim:mainfrom
ashsolei:fix/validate-secondary-link-url
Closed

fix: validate secondary_link URL when value is present#895
ashsolei wants to merge 1 commit intohesreallyhim:mainfrom
ashsolei:fix/validate-secondary-link-url

Conversation

@ashsolei
Copy link

@ashsolei ashsolei commented Mar 1, 2026

Problem

The URL validation loop in parse_issue_form.py skips secondary_link entirely:

if value and field != "secondary_link":  # secondary is optional

This means a secondary_link containing spaces or missing the https:// 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 continue on empty values:

if not value:
    continue  # required-field check above handles primary_link/author_link

Non-empty values are now validated regardless of which field they belong to. The required-field check earlier in validate_parsed_data() already ensures primary_link and author_link are present, so skipping empty optional fields is safe.

1 file changed, 6 insertions, 5 deletions. All 314 tests pass.

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.
Copilot AI review requested due to automatic review settings March 1, 2026 03:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 for https:// prefix and spaces.

@ashsolei ashsolei closed this Mar 1, 2026
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.

2 participants