affaan-m/ECC · error · ConfigError
Invalid JSON in config
Error message
Invalid JSON in config: {path} What it means
Illustrative pattern from the python-patterns skill: the config file was opened successfully but json parsing failed, so the contents are not valid JSON and a ConfigError with the path is raised (chained from JSONDecodeError). The file's contents, not its absence, are the problem.
Solutions
- Report line/column from the chained JSONDecodeError to the user
- Validate configs against a schema after parsing
- Fail fast at startup instead of returning partially initialized config
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at skills/python-patterns/SKILL.md:153 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of affaan-m/ECC@d8409a4b08 (2026-08-26).
Data as JSON: /api/errors/95fee8ce8247bee5.
Report an issue: GitHub.
Appendix: source
Thrown at skills/python-patterns/SKILL.md:153
def render_all(items: list[Renderable]) -> str:
"""Render all items that implement the Renderable protocol."""
return "\n".join(item.render() for item in items)
```
## Error Handling Patterns
### Specific Exception Handling
```python
# Good: Catch specific exceptions
def load_config(path: str) -> Config:
try:
with open(path) as f:
return Config.from_json(f.read())
except FileNotFoundError as e:
raise ConfigError(f"Config file not found: {path}") from e
except json.JSONDecodeError as e:
raise ConfigError(f"Invalid JSON in config: {path}") from e
# Bad: Bare except
def load_config(path: str) -> Config:
try:
with open(path) as f:
return Config.from_json(f.read())
except:
return None # Silent failure!
```
### Exception Chaining
```python
def process_data(data: str) -> Result:
try:
parsed = json.loads(data)
except json.JSONDecodeError as e:
# Chain exceptions to preserve the tracebackView on GitHub (pinned to d8409a4b08)