Commit f2371529a6

f2371529a655dc495ee174131b4ddafa7cecdc3b

parent: eaf354113b

Unsigned

Alicia Sykes <alicia@omg.lol> ยท 2026-10-11 21:46 UTC

Adds crash proofing to mas-deletion, and moves from error to warn

Layout: unified ยท split

.github/CONTRIBUTING.md +1 โˆ’1
@@ -285,8 +285,8 @@ Below is the full list of checks - it's basically the same as what is listed in
285- **Validating Addition** 285- **Validating Addition**
286 - ๐Ÿ”ด **Schema valid** - YAML must pass schema validation 286 - ๐Ÿ”ด **Schema valid** - YAML must pass schema validation
287 - ๐Ÿ”ด **Required fields** - Must include `name`, `description`, `url`, `icon` 287 - ๐Ÿ”ด **Required fields** - Must include `name`, `description`, `url`, `icon`
288 - ๐Ÿ”ด **No mass changes** - Must not remove more than 5, or modify more than 10, existing listings
289 - ๐ŸŸก **Single entry** - Only one service addition per PR 288 - ๐ŸŸก **Single entry** - Only one service addition per PR
289 - ๐ŸŸก **No mass changes** - Should not remove more than 5, or modify more than 10, existing listings
290 - ๐ŸŸก **Position** - New entries must go at the end of their section 290 - ๐ŸŸก **Position** - New entries must go at the end of their section
291 - ๐ŸŸก **Open source** - Non-open-source submissions need justification 291 - ๐ŸŸก **Open source** - Non-open-source submissions need justification
292 - ๐ŸŸก **Duplicate name** - Service name must not already exist 292 - ๐ŸŸก **Duplicate name** - Service name must not already exist
lib/checks/check-additions.py +8 โˆ’7
@@ -174,9 +174,10 @@ def check_single_entry(diff):
174 174
175 175
176def check_mass_changes(diff): 176def check_mass_changes(diff):
177 """Return a finding if the diff removes or modifies too many existing services.""" 177 """Return a finding if the diff removes or modifies too many existing services, excluding moves."""
178 services = diff.get("services", {}) 178 services = diff.get("services", {})
179 removed = len(services.get("removed", [])) 179 added_names = {s.get("service") for s in services.get("added", [])}
180 removed = sum(1 for s in services.get("removed", []) if s.get("service") not in added_names)
180 modified = len(services.get("modified", [])) 181 modified = len(services.get("modified", []))
181 if removed > MAX_REMOVED_LISTINGS or modified > MAX_MODIFIED_LISTINGS: 182 if removed > MAX_REMOVED_LISTINGS or modified > MAX_MODIFIED_LISTINGS:
182 return MASS_CHANGE_MSG.format(removed=removed, modified=modified) 183 return MASS_CHANGE_MSG.format(removed=removed, modified=modified)
@@ -187,7 +188,7 @@ def _added_keys(diff):
187 """Build a set of (category, section, lowercase_name) for added services.""" 188 """Build a set of (category, section, lowercase_name) for added services."""
188 keys = set() 189 keys = set()
189 for svc in diff.get("services", {}).get("added", []): 190 for svc in diff.get("services", {}).get("added", []):
190 name = svc.get("fields", {}).get("name", "").lower().strip() 191 name = (svc.get("fields", {}).get("name") or "").lower().strip()
191 keys.add((svc.get("category", ""), svc.get("section", ""), name)) 192 keys.add((svc.get("category", ""), svc.get("section", ""), name))
192 return keys 193 return keys
193 194
@@ -203,7 +204,7 @@ def build_name_index(head, diff):
203 for sec in cat.get("sections", []): 204 for sec in cat.get("sections", []):
204 sn = sec.get("name", "") 205 sn = sec.get("name", "")
205 for svc in sec.get("services", []): 206 for svc in sec.get("services", []):
206 name = svc.get("name", "").lower().strip() 207 name = (svc.get("name") or "").lower().strip()
207 if name and (cn, sn, name) not in exclude: 208 if name and (cn, sn, name) not in exclude:
208 index[name] = f"{cn} > {sn}" 209 index[name] = f"{cn} > {sn}"
209 return index 210 return index
@@ -220,7 +221,7 @@ def build_url_index(head, diff):
220 for sec in cat.get("sections", []): 221 for sec in cat.get("sections", []):
221 sn = sec.get("name", "") 222 sn = sec.get("name", "")
222 for svc in sec.get("services", []): 223 for svc in sec.get("services", []):
223 name = svc.get("name", "").lower().strip() 224 name = (svc.get("name") or "").lower().strip()
224 if (cn, sn, name) in exclude: 225 if (cn, sn, name) in exclude:
225 continue 226 continue
226 url = svc.get("url", "") 227 url = svc.get("url", "")
@@ -232,7 +233,7 @@ def build_url_index(head, diff):
232def check_duplicate_name(diff, name_index): 233def check_duplicate_name(diff, name_index):
233 """Return a finding if an added service name already exists in the YAML.""" 234 """Return a finding if an added service name already exists in the YAML."""
234 for svc in diff.get("services", {}).get("added", []): 235 for svc in diff.get("services", {}).get("added", []):
235 name = svc.get("fields", {}).get("name", "").lower().strip() 236 name = (svc.get("fields", {}).get("name") or "").lower().strip()
236 if name and name in name_index: 237 if name and name in name_index:
237 return DUPLICATE_NAME_MSG.format( 238 return DUPLICATE_NAME_MSG.format(
238 name=svc["fields"]["name"], location=name_index[name], 239 name=svc["fields"]["name"], location=name_index[name],
@@ -315,7 +316,7 @@ def main():
315 316
316 checks = [ 317 checks = [
317 ("single-entry", check_single_entry(diff), False), 318 ("single-entry", check_single_entry(diff), False),
318 ("mass-changes", check_mass_changes(diff), True), 319 ("mass-changes", check_mass_changes(diff), False),
319 ("required-fields", check_required_fields(diff, head), True), 320 ("required-fields", check_required_fields(diff, head), True),
320 ("position", check_position(diff, head), False), 321 ("position", check_position(diff, head), False),
321 ("open-source", check_open_source(diff), False), 322 ("open-source", check_open_source(diff), False),