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
285285- **Validating Addition**
286286 - 🔴 **Schema valid** - YAML must pass schema validation
287287 - 🔴 **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
289288 - 🟡 **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
290290 - 🟡 **Position** - New entries must go at the end of their section
291291 - 🟡 **Open source** - Non-open-source submissions need justification
292292 - 🟡 **Duplicate name** - Service name must not already exist
lib/checks/check-additions.py +8 −7
@@ -174,9 +174,10 @@ def check_single_entry(diff):
174174
175175
176176def 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."""
178178 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)
180181 modified = len(services.get("modified", []))
181182 if removed > MAX_REMOVED_LISTINGS or modified > MAX_MODIFIED_LISTINGS:
182183 return MASS_CHANGE_MSG.format(removed=removed, modified=modified)
@@ -187,7 +188,7 @@ def _added_keys(diff):
187188 """Build a set of (category, section, lowercase_name) for added services."""
188189 keys = set()
189190 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()
191192 keys.add((svc.get("category", ""), svc.get("section", ""), name))
192193 return keys
193194
@@ -203,7 +204,7 @@ def build_name_index(head, diff):
203204 for sec in cat.get("sections", []):
204205 sn = sec.get("name", "")
205206 for svc in sec.get("services", []):
206 name = svc.get("name", "").lower().strip()
207 name = (svc.get("name") or "").lower().strip()
207208 if name and (cn, sn, name) not in exclude:
208209 index[name] = f"{cn} > {sn}"
209210 return index
@@ -220,7 +221,7 @@ def build_url_index(head, diff):
220221 for sec in cat.get("sections", []):
221222 sn = sec.get("name", "")
222223 for svc in sec.get("services", []):
223 name = svc.get("name", "").lower().strip()
224 name = (svc.get("name") or "").lower().strip()
224225 if (cn, sn, name) in exclude:
225226 continue
226227 url = svc.get("url", "")
@@ -232,7 +233,7 @@ def build_url_index(head, diff):
232233def check_duplicate_name(diff, name_index):
233234 """Return a finding if an added service name already exists in the YAML."""
234235 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()
236237 if name and name in name_index:
237238 return DUPLICATE_NAME_MSG.format(
238239 name=svc["fields"]["name"], location=name_index[name],
@@ -315,7 +316,7 @@ def main():
315316
316317 checks = [
317318 ("single-entry", check_single_entry(diff), False),
318 ("mass-changes", check_mass_changes(diff), True),
319 ("mass-changes", check_mass_changes(diff), False),
319320 ("required-fields", check_required_fields(diff, head), True),
320321 ("position", check_position(diff, head), False),
321322 ("open-source", check_open_source(diff), False),