mirror of
https://github.com/MadsLorentzen/ai-job-search.git
synced 2026-11-02 13:12:50 +00:00
fix(job-key): report a non-object state file in --audit instead of a traceback (#626)
doc.get("seen", doc) raised AttributeError on a top-level array, and
entry.get("url") raised it on an entry that was not an object, so the
existing "expected an object of job entries" message was never reached.
Guard both and exit 1 with a one-line message.
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1bb3bee2f2
commit
9c802a4aa2
3 files changed
+32
-1
No files matched your search
+5
-1
@@ -183,10 +183,14 @@ def audit(path: Path) -> int:
|
||||
except (OSError, json.JSONDecodeError) as exc:
|
||||
print(f"cannot read {path}: {exc}", file=sys.stderr)
|
||||
return 1
|
||||
seen = doc.get("seen", doc)
|
||||
seen = doc.get("seen", doc) if isinstance(doc, dict) else doc
|
||||
if not isinstance(seen, dict):
|
||||
print(f"{path}: expected an object of job entries", file=sys.stderr)
|
||||
return 1
|
||||
not_objects = [k for k, v in seen.items() if not isinstance(v, dict)]
|
||||
if not_objects:
|
||||
print(f"{path}: entry is not an object: {not_objects[0]}", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
malformed = [k for k in seen if not is_canonical(k) and not is_legacy_shape(k)]
|
||||
legacy = [k for k in seen if is_legacy_shape(k)]
|
||||
|
||||
Reference in new issue
Block a user