Skip to content

Commit 3d91a42

Browse files
committed
Fix bugs in validate-changelog-yaml.py (#4414)
(cherry picked from commit 17747f3)
1 parent 3944e4e commit 3d91a42

1 file changed

Lines changed: 33 additions & 5 deletions

File tree

.github/scripts/validate-changelog-yaml.py

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
- Contains required 'authors' field with at least one author
3030
- Each author has a 'name' field (non-empty string)
3131
- Contains either 'links' or 'issues' field (or both)
32-
- If 'issues' is present, it must be an integer not exceeding 17000
32+
- If 'issues' is present, it must be a list of integers not exceeding 17000
33+
- If 'links' is present, each entry must be a mapping with 'name' and 'url' fields (not a plain string)
34+
- Comment block is removed
3335
"""
3436

3537
import sys
@@ -113,12 +115,38 @@ def validate_changelog_yaml(file_path):
113115

114116
# Validate 'issues' field if present
115117
if 'issues' in data:
116-
if not isinstance(data['issues'], int):
117-
print(f"::error file={file_path}::Field 'issues' must be an integer")
118+
if not isinstance(data['issues'], list):
119+
print(f"::error file={file_path}::Field 'issues' must be a list of integers")
118120
return False
119-
if data['issues'] > 17000:
120-
print(f"::error file={file_path}::Field 'issues' value {data['issues']} points to a non-existing github PR. Did you intend to reference a JIRA issue, please use 'links'.")
121+
for i, issue in enumerate(data['issues']):
122+
if not isinstance(issue, int):
123+
print(f"::error file={file_path}::Field 'issues' entry {i} must be an integer")
124+
return False
125+
if issue > 17000:
126+
print(f"::error file={file_path}::Field 'issues' value {issue} points to a non-existing github PR. Did you intend to reference a JIRA issue, please use 'links'.")
127+
return False
128+
129+
# Validate 'links' field if present
130+
if 'links' in data:
131+
if not isinstance(data['links'], list):
132+
print(f"::error file={file_path}::Field 'links' must be a list")
121133
return False
134+
for i, link in enumerate(data['links']):
135+
if not isinstance(link, dict):
136+
print(f"::error file={file_path}::Link {i} must be a mapping with 'name' and 'url' fields, not a plain string")
137+
return False
138+
if 'name' not in link or not link['name']:
139+
print(f"::error file={file_path}::Link {i} missing or empty 'name' field")
140+
return False
141+
if not isinstance(link['name'], str) or not link['name'].strip():
142+
print(f"::error file={file_path}::Link {i} 'name' must be a non-empty string")
143+
return False
144+
if 'url' not in link or not link['url']:
145+
print(f"::error file={file_path}::Link {i} missing or empty 'url' field")
146+
return False
147+
if not isinstance(link['url'], str) or not link['url'].strip():
148+
print(f"::error file={file_path}::Link {i} 'url' must be a non-empty string")
149+
return False
122150

123151
# All validations passed
124152
print(f"✓ {file_path} is valid")

0 commit comments

Comments
 (0)