fix: parse_resource still corrupts every https:// resource - off-by-one from #1325 never fixed
Summary
parse_resource in src/utils/url_validator.py still corrupts every labeled resource URL — the exact bug reported in #1325 (closed) was never actually fixed. The split marker ": http" is a prefix of ": https://", so splitting on it chops http off every https:// resource, leaving a broken s://... URL.
Evidence
src/utils/url_validator.py:69-75:
split_marker = ": http"
idx = raw.find(split_marker)
if idx != -1:
label = raw[:idx].strip()
url = raw[idx + len(split_marker):].strip()
Verified by execution:
parse_resource("Python official docs: https://docs.python.org")
-> {"label": "Python official docs", "url": "s://docs.python.org"} # corrupt
parse_resource("MDN Docs: https://developer.mozilla.org/")
-> url = "s://developer.mozilla.org/" # corrupt
data/projects.json contains ~100 labeled resources in the "Label: https://..." form, so all of them are corrupted:
/api/project/<id>/resources(main_routes.py:315viavalidate_resources) flags them all as invalid.data_loader.validate_projectslogs spurious warnings for every one.tests/test_url_validator.py:123-127, 138-143, 202-206assert the correct output and therefore fail against the current code.
Impact
- Every learning resource link rendered by the project detail page is a broken
s://...URL. - The shipped test suite for
url_validatoris failing. - #1325 ("add off-by-one fix in url_validator.py parse_resource") was closed, but the fix is not present — this is a regression/open-bug against that fix.
Suggested Fix
Split on the scheme token properly, e.g. find ": " and slice the URL starting at "http" (url = raw[idx+2:].lstrip() or regex r"^(.+?):\s*(https?://.*)$"), and add a regression test using a https:// label.
Related minor flaw in the same function: the marker is case-sensitive, so "Docs: HTTPS://example.com" isn't split at all and is treated as a bare URL.
/assign
Hey @prathamc00, this issue is already assigned to @ionfwsrijan. Please find another open issue!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions!
@ionfwsrijan Assigned...Start working on the pull request