Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance code generator error reporting #55

Open
pljakobs opened this issue Oct 10, 2024 · 3 comments
Open

enhance code generator error reporting #55

pljakobs opened this issue Oct 10, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@pljakobs
Copy link
Contributor

code generator currently relies on the python traceback to provide insight on failure of compiling the schema.
It would be good to at least see the offending schema line to be able to more easily correct issues.

CFGDB app-config.cfgdb app-data.cfgdb defs.cfgdb
Parsing app-config ...
Parsing app-data ...
Parsing defs ...
Traceback (most recent call last):
  File "/home/pjakobs/devel/esp_rgbww_firmware/Components/ConfigDB/tools/dbgen.py", line 1406, in <module>
    main()
  File "/home/pjakobs/devel/esp_rgbww_firmware/Components/ConfigDB/tools/dbgen.py", line 1395, in main
    parse_database(db)
  File "/home/pjakobs/devel/esp_rgbww_firmware/Components/ConfigDB/tools/dbgen.py", line 679, in parse_database
    parse_properties(root, database.schema['properties'])
                           ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
KeyError: 'properties'
make: *** [/home/pjakobs/devel/esp_rgbww_firmware/Components/ConfigDB/component.mk:25: /home/pjakobs/devel/esp_rgbww_firmware/out/ConfigDB/app-config.h] Fehler 1

@mikee47
Copy link
Owner

mikee47 commented Oct 10, 2024

Agree this would be helpful. I note that JSON formatting errors already do this, but that's a feature of the python JSON decoder.

It would be nice if errors like the one above could be caught by the schema validator, since properties isn't optional here. The code generator runs the schema through though a Draft7Validator but don't think its ever actually caught anything! Maybe some kind of custom schema to validate the .cfgdb schema would help.

I can't see any direct way to associate line numbers with decoded JSON, but it would be fairly straightforward to track and print the parsing location as a JSON pointer (e.g. basic_config/properties/channels/items/properties/pin/default)

@mikee47 mikee47 added the enhancement New feature or request label Oct 10, 2024
@mikee47
Copy link
Owner

mikee47 commented Oct 13, 2024

Some improvements in #57, perhaps this will suffice?

@pljakobs
Copy link
Contributor Author

I've seen a useful error while building with the external schema change, have not tried it with deliberately broken schema definitions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants