Skip to content

Commit dedc2b7

Browse files
committed
add target repository validation
1 parent 3c5a425 commit dedc2b7

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

.github/scripts/labelling-correction-helpers.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ function normalizeText(text, maxLength = MAX_DISCUSSION_BODY_LENGTH) {
4343
}
4444

4545
function parseTargetRepository(fullName) {
46-
const trimmed = (fullName || "").trim() || DEFAULT_TARGET_REPOSITORY;
46+
const trimmed = (fullName || "").trim();
47+
if (!trimmed) {
48+
throw new Error("Missing target repository");
49+
}
50+
4751
const [owner, repo] = trimmed.split("/");
4852
if (!owner || !repo) {
4953
throw new Error(`Invalid repository value '${trimmed}'`);
@@ -106,12 +110,8 @@ function normalizeDispatchPayload(rawPayload) {
106110
actor,
107111
createdAt: dispatchData.createdAt || new Date().toISOString(),
108112
},
109-
target_repository: parseTargetRepository(
110-
dispatchData.target_repository
111-
|| dispatchData.target_repo
112-
|| dispatchData.repository
113-
|| DEFAULT_TARGET_REPOSITORY
114-
),
113+
// source_repository in the dispatch payload is the discussions repo where the discussion lives.
114+
target_repository: parseTargetRepository(dispatchData.source_repository),
115115
};
116116
}
117117

0 commit comments

Comments
 (0)