Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,13 @@ def validate_credentials(
if not project or not project.strip():
return False, "Missing project id or path"

# GitLab addresses a project by its numeric id or a group/project path. A pasted URL or a bare
# group name otherwise URL-encodes into a nonsense path, 404s, and gets reported as "not found
# or not accessible with this token" — which points the user at the token rather than the format.
# GitLab addresses a project by its numeric id or a group/project path. A pasted URL, a bare
# group name, or a stray leading, trailing, or doubled slash otherwise URL-encodes into a
# nonsense path, 404s, and gets reported as "not found or not accessible with this token", which
# points the user at the token rather than the format.
project_ref = project.strip()
if "://" in project_ref or ("/" not in project_ref and not project_ref.isdigit()):
segments = project_ref.split("/")
if not project_ref.isdigit() and ("://" in project_ref or len(segments) < 2 or not all(segments)):
return (
False,
"Enter the project as group/project (for example, mygroup/myproject) or its numeric project ID, not a full URL.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,9 @@ def test_missing_inputs_short_circuit(self, host, token, project, expected_msg):
"https://gitlab.com/mygroup/", # pasted URL
"mygroup", # bare group, no project and not a numeric id
"some-dashboard", # bare name
"/myproject", # leading slash: encodes to an empty group segment
"mygroup/", # trailing slash: encodes to an empty project segment
"mygroup//myproject", # doubled slash: encodes to an empty middle segment
],
)
def test_malformed_project_gets_format_guidance(self, project):
Expand Down
Loading