Config-code sync checker for Autohive integrations.
Requires: Python 3.13+
This script validates that the config.json file and the integration's Python code are in sync. It scans all .py files in the integration directory (not just the entry point), supporting modular integrations where action handlers are split across multiple files. It uses AST (Abstract Syntax Tree) parsing to extract @action decorators and inputs access patterns from the code, then cross-validates them against the actions and input schemas declared in config.json.
python scripts/check_config_sync.py <dir> [dir ...]| Argument | Required | Description |
|---|---|---|
dir |
Yes (one or more) | Path to an integration directory to check |
| Code | Meaning |
|---|---|
0 |
Config and code are in sync |
1 |
One or more sync errors found |
2 |
An error occurred during processing (missing files, parse error, usage error) |
The script performs five checks:
Verifies that every action declared in config.json has a corresponding @action-decorated function in the code, and vice versa.
- Config-only actions: declared in
config.jsonbut no matching@actiondecorator in the code - Code-only actions: decorated with
@actionin the code but not listed inconfig.json
Checks that every input parameter defined in the config.json schema for an action is actually accessed in the corresponding function's code.
- Detects dead schema fields that are declared but never used
Checks that every inputs key accessed in the code has a corresponding entry in the config.json schema.
- Detects undocumented parameters that are used in code but missing from the config
Validates that the required/optional status of parameters in config.json matches how they are accessed in the code (e.g., parameters accessed with .get() or default values should be optional).
Ensures that action names in config.json exactly match the decorator arguments or function names used in the code, catching typos and naming drift.
flowchart TD
A[Read config.json] --> B[Parse actions and input schemas]
B --> C[Find all .py files in integration dir]
C --> D[Parse each file with AST]
D --> E[Extract @action decorators]
D --> F[Extract inputs access patterns]
E --> G{Actions match?}
G -->|Mismatch| H[Record errors]
G -->|Match| I{Input params match?}
F --> I
B --> I
I -->|Mismatch| H
I -->|Match| J{All checks passed?}
H --> J
J -->|No| K[Print report, exit 1]
J -->|Yes| L[Exit 0]
- Read
config.jsonand extract declared actions and their input schemas - Scan all
.pyfiles in the integration directory (supporting modular layouts) - Parse each file into an Abstract Syntax Tree (no code execution)
- Extract
@actiondecorator names andinputskey access patterns from the AST - Compare actions between config and code — report any mismatches
- Compare input parameters for each action — report undocumented, dead, or mismatched fields
- Report all errors and warnings
🔗 Checking config-code sync...
✅ Config-code sync OK
On failure:
🔗 Checking config-code sync...
⚠️ Action 'send_email' in config.json but not found in code
❌ Input 'recipient' declared in config.json but never accessed in code
❌ Input 'priority' accessed in code but missing from config.json schema
❌ Config-code sync errors found
Fix: Ensure config.json actions and input schemas match the code
Run locally: python scripts/check_config_sync.py <dir>
- Python 3.13+ — for
ast,json, andpathlibstandard library modules
No external dependencies are required. The script uses only Python's standard library.
This script is called by check_code.py as the final check step (step 9). It runs after all other quality checks have passed. It is also exercised independently by the self-test.yml workflow against test examples in tests/examples/.
# Called internally by check_code.py:
from check_config_sync import check_config_sync
check_config_sync(str(dir_path))