Skip to content

Commit dcf3176

Browse files
committed
fix(gitlab): validate ref via commits endpoint so tags and commit SHAs are accepted, not just branches
1 parent 82eb919 commit dcf3176

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

apps/sim/connectors/gitlab/gitlab.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,18 +1067,21 @@ export const gitlabConnector: ConnectorConfig = {
10671067

10681068
const userRef = typeof sourceConfig.ref === 'string' ? sourceConfig.ref.trim() : ''
10691069
if (userRef && activePhases(choice).includes('repo')) {
1070-
const branchResponse = await fetchWithRetry(
1071-
`${apiBase}/projects/${encodedProject}/repository/branches/${encodeURIComponent(userRef)}`,
1070+
const refResponse = await fetchWithRetry(
1071+
`${apiBase}/projects/${encodedProject}/repository/commits/${encodeURIComponent(userRef)}`,
10721072
{ method: 'GET', headers: authHeaders(accessToken) },
10731073
VALIDATE_RETRY_OPTIONS
10741074
)
1075-
if (branchResponse.status === 404) {
1076-
return { valid: false, error: `Branch "${userRef}" not found in project "${project}"` }
1075+
if (refResponse.status === 404) {
1076+
return {
1077+
valid: false,
1078+
error: `Branch, tag, or commit "${userRef}" not found in project "${project}"`,
1079+
}
10771080
}
1078-
if (!branchResponse.ok) {
1081+
if (!refResponse.ok) {
10791082
return {
10801083
valid: false,
1081-
error: `Cannot verify branch "${userRef}": ${branchResponse.status}`,
1084+
error: `Cannot verify ref "${userRef}": ${refResponse.status}`,
10821085
}
10831086
}
10841087
}

0 commit comments

Comments
 (0)