Last active
July 15, 2025 22:46
-
-
Save BigRoy/5937763e10c74781779716b0aae3060a to your computer and use it in GitHub Desktop.
Find invalid JSON environment entries in stored AYON applications settings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import ayon_api | |
| import json | |
| addon_name = "applications" | |
| addons = ayon_api.get_addons_info()["addons"] | |
| applications_addon = next(addon for addon in addons if addon["name"] == addon_name) | |
| variants = ["production", "staging"] # ignore dev bundles for now | |
| for addon_version, version_info in applications_addon["versions"].items(): | |
| if not version_info["hasSettings"]: | |
| continue | |
| for variant in variants: | |
| response = ayon_api.get(f"addons/{addon_name}/{addon_version}/rawOverrides", variant=variant) | |
| overrides = response.data | |
| if not overrides: | |
| continue | |
| # For the overrides, find all the 'environment' keys | |
| def traverse(d, path=""): | |
| """Simple settings dict traversal | |
| Yields each settings path with its value. | |
| """ | |
| if isinstance(d, dict): | |
| for key, value in d.items(): | |
| for result in traverse(value, path=f"{path}/{key}"): | |
| yield result | |
| elif isinstance(d, list): | |
| for i, value in enumerate(d): | |
| for result in traverse(value, path=f"{path}/{i}"): | |
| yield result | |
| yield path, d | |
| # Get invalid entries by testing a json decode | |
| invalid = [] | |
| for path, data in traverse(overrides, path=f"ayon+settings://{addon_name}"): | |
| if path.endswith("/environment") and isinstance(data, str): | |
| # Assuming this is an enviroment value, let's validate it | |
| try: | |
| json.loads(data) | |
| except json.JSONDecodeError as exc: | |
| invalid.append((path, data, exc)) | |
| # Print invalid entries | |
| if invalid: | |
| print(f"### {addon_name} {addon_version} [{variant}]\n") | |
| for path, data, exc in invalid: | |
| print(f"Key: `{path}`") | |
| print("```json") | |
| print(data) | |
| print("```") | |
| print("Error:", exc) | |
| print("") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to
You can run the above Python script in AYON Launcher's > Admin > Console.
Result
Example output is in Markdown, like:
Which becomes:
applications 1.1.0 [production]
Key:
ayon+settings://applications/applications/adsk_3dsmax/environment{} dsaError: Extra data: line 1 column 4 (char 3)
applications 1.1.0 [staging]
Key:
ayon+settings://applications/applications/adsk_3dsmax/environment{} dsaError: Extra data: line 1 column 4 (char 3)
Still stuck?
You can paste the individual JSON blocks if they are invalid to e.g. https://jsonlint.com/ or just ask ChatGPT to find what's wrong with the JSON - most likely it'll do a fine job explaining what's wrong.