Skip to content

fix: installer crashes with AttributeError when WeasyPrint warns to stdout - #40

Open
satriachandrayw wants to merge 1 commit into
AgriciDaniel:mainfrom
satriachandrayw:fix/parse-json-stdout
Open

fix: installer crashes with AttributeError when WeasyPrint warns to stdout#40
satriachandrayw wants to merge 1 commit into
AgriciDaniel:mainfrom
satriachandrayw:fix/parse-json-stdout

Conversation

@satriachandrayw

Copy link
Copy Markdown

Problem

Installer fails at bootstrap with:

[ERROR] Codex SEO runtime bootstrap failed.
AttributeError: 'NoneType' object has no attribute 'get'

Root cause chain:

  1. WeasyPrint missing system libs (libgobject-2.0-0) emits warning text to stdout before JSON
  2. parse_json_stdout calls json.loads() on mixed output → JSONDecodeError → returns None
  3. verification: None propagates into bootstrap result
  4. print_bootstrap_diagnostics calls payload.get("verification", {}).get("notes", []) — Python's .get(key, default) returns None when key exists but value is None, not the default
  5. .get() on NoneAttributeError

Note: bootstrap actually succeeds (ready: true in verify output) but gets reported as failure.

Changes

scripts/bootstrap_environment.pyparse_json_stdout:

  • Extract JSON by finding first { when json.loads() fails on mixed stdout
  • Handles any tool/library that emits warnings before JSON output

install.shprint_bootstrap_diagnostics:

  • (payload.get("verification") or {}).get("notes", []) — guard against None verification

Verification

Before fix: verification=None, ok=False, crash in diagnostics
After fix: verification=dict, ok=True, notes populated with WeasyPrint warning

WeasyPrint emits warning text to stdout before its JSON output when
system libraries (pango/cairo/gobject) are missing. json.loads() fails
on the mixed output, causing parse_json_stdout to return None.

This cascades into:
- verification=None in the bootstrap result
- print_bootstrap_diagnostics calling .get() on None (AttributeError)
- bootstrap reporting ok=False even when ready=True

Changes:
- parse_json_stdout: extract JSON by finding first '{' when json.loads fails
- print_bootstrap_diagnostics: guard against None verification with 'or {}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant