[GH-ISSUE #39] Make config errors more easy to debug #27

Closed
opened 2026-05-22 21:50:45 +01:00 by JakeStanger · 5 comments
Owner

Originally created by @JustSimplyKyle on GitHub (Nov 29, 2022).
Original GitHub issue: https://github.com/JakeStanger/ironbar/issues/39

Currently I'm in the middle of writing a config.
image
I'm... trying to debug? but the error msg isn't exactly useful
image
I hope that at least we can add an message to tell the user which line of the config has gone wrong

Originally created by @JustSimplyKyle on GitHub (Nov 29, 2022). Original GitHub issue: https://github.com/JakeStanger/ironbar/issues/39 Currently I'm in the middle of writing a config. ![image](https://user-images.githubusercontent.com/68589851/204546863-374d3994-92b4-465b-b7cb-4bc4fef0402a.png) I'm... trying to debug? but the error msg isn't exactly useful ![image](https://user-images.githubusercontent.com/68589851/204546942-7d70ae36-e3fc-4990-974d-dc2d174ddee0.png) I hope that at least we can add an message to tell the user which line of the config has gone wrong
Author
Owner

@JustSimplyKyle commented on GitHub (Nov 29, 2022):

Another example:
image

<!-- gh-comment-id:1330692243 --> @JustSimplyKyle commented on GitHub (Nov 29, 2022): Another example: ![image](https://user-images.githubusercontent.com/68589851/204548594-e7d0d1bf-c8d8-4a0c-adc3-d0907106d038.png)
Author
Owner

@JakeStanger commented on GitHub (Nov 29, 2022):

Hey, yep noticed this yesterday with my own config when I pushed up the breaking changes. A lot of the problem seems to come from Serde and the way untagged enums work - basically it "guesses" the different config options for multiple monitors/bars and if there's anything invalid inside that block (ie the whole bar config) it nopes out.

I also recently updated Corn which adds direct deserialization support, but that doesn't give you line numbers yet which is...inconvenient.

I've got to do some planning around what I can do to resolve that as I don't think it's particularly trivial. For now, I'd recommend the following:

  • Make sure you're aware of the breaking changes present in each of the commits from last night (sys-modules and its tokens -> snake_case; script path -> cmd; custom exec -> on_click)
  • Use a flat config (ie same config for all bars, don't specify monitors) for debugging.
  • Use JSON (or YAML/TOML) for debugging the config. You can use the corn-cli crate to easily convert Corn to any of those.
<!-- gh-comment-id:1330703717 --> @JakeStanger commented on GitHub (Nov 29, 2022): Hey, yep noticed this yesterday with my own config when I pushed up the breaking changes. A lot of the problem seems to come from Serde and the way untagged enums work - basically it "guesses" the different config options for multiple monitors/bars and if there's anything invalid inside that block (ie the whole bar config) it nopes out. I also recently updated Corn which adds direct deserialization support, but that doesn't give you line numbers yet which is...inconvenient. I've got to do some planning around what I can do to resolve that as I don't think it's particularly trivial. For now, I'd recommend the following: - Make sure you're aware of the breaking changes present in each of the commits from last night (sys-modules and its tokens -> snake_case; script path -> cmd; custom exec -> on_click) - Use a flat config (ie same config for all bars, don't specify monitors) for debugging. - Use JSON (or YAML/TOML) for debugging the config. You can use the `corn-cli` crate to easily convert Corn to any of those.
Author
Owner

@JakeStanger commented on GitHub (Nov 29, 2022):

Looks like there has been a long-standing PR for this in Serde that so far hasn't gained any response from maintainers. It may be possible to patch this in, but I wouldn't be able to publish a patched version to crates.io

https://github.com/serde-rs/serde/pull/1544

It may also be possible to write a custom deserializer to try and better capture the errors.

<!-- gh-comment-id:1331439644 --> @JakeStanger commented on GitHub (Nov 29, 2022): Looks like there has been a long-standing PR for this in Serde that so far hasn't gained any response from maintainers. It may be possible to patch this in, but I wouldn't be able to publish a patched version to crates.io https://github.com/serde-rs/serde/pull/1544 It may also be possible to write a custom deserializer to try and better capture the errors.
Author
Owner

@JakeStanger commented on GitHub (Nov 29, 2022):

Actually sorry @JustSimplyKyle it looks like I actually misunderstood the main problem in my first response (hurriedly answered at lunch...). This is a problem with the Corn file not being valid, rather than any config changes in Ironbar. That means if you use corn-cli as above you should get much more detailed error output.

I'll leave this open as there clearly does need to be improvements across the board, but the issue you described is out of scope & needs an issue in Corn instead.

<!-- gh-comment-id:1331442929 --> @JakeStanger commented on GitHub (Nov 29, 2022): Actually sorry @JustSimplyKyle it looks like I actually misunderstood the main problem in my first response (hurriedly answered at lunch...). This is a problem with the Corn file not being valid, rather than any config changes in Ironbar. That means if you use `corn-cli` as above you should get much more detailed error output. I'll leave this open as there clearly does need to be improvements across the board, but the issue you described is out of scope & needs an issue in [Corn](https://github.com/jakestanger/corn/issues) instead.
Author
Owner

@JakeStanger commented on GitHub (Dec 12, 2022):

Right, two big improvements on the way:

  1. I've updated Corn to surface parsing errors in their full detail, which means you now get a full set of info for invalid syntax. JSON/TOML/YAML already did this, although not in as much detail.
2022-12-12T23:00:30.509991Z ERROR ironbar: 
   0: Invalid Corn config
   1: An error while parsing the input file.
   1:  --> 2:22
        |
      2 |     monitors.DP-1 =  }
        |                      ^---
        |
        = expected object, array, boolean, null, string, integer, float, or input
   1: 
  1. I have implemented a custom deserializer for the config which gives you some idea of what's invalid. Until Serde improves its untagged enum error handling, this is as good as we'll get.
2022-12-12T23:08:49.796950Z ERROR ironbar: 
   0: Invalid Corn config
   1: An error occurred when deserializing: 
         0: An invalid config was found. The following errors were encountered:
         1: single-bar (b): unknown variant `dfjdjf`, expected one of `clock`, `mpd`, `tray`, `workspaces`, `sys_info`, `launcher`, `script`, `focused`, `custom`
         2:  multi-bar (c): invalid type: map, expected a sequence

      Location:
         src/config.rs:67

      Note: Both the single-bar (type b / error 1) and multi-bar (type c / error 2) config variants were tried. You can likely ignore whichever of these is not relevant to you.
      Suggestion: Please see https://github.com/JakeStanger/ironbar/wiki/configuration-guide#2-pick-your-use-case for more info on the above

2022-12-12T23:12:45.282254Z ERROR ironbar: 
   0: Invalid Corn config
   1: An error occurred when deserializing: Expected array, found 'String("dkfdfkd")'

As for the last example, I've no idea since this is coming from the bar itself rather than loading the config. Hopefully the refactoring I merged in yesterday I got it.

Hoping to merge in the above in the next couple of days.

<!-- gh-comment-id:1347472271 --> @JakeStanger commented on GitHub (Dec 12, 2022): Right, two big improvements on the way: 1. I've updated Corn to surface parsing errors in their full detail, which means you now get a full set of info for invalid syntax. JSON/TOML/YAML already did this, although not in as much detail. ``` 2022-12-12T23:00:30.509991Z ERROR ironbar: 0: Invalid Corn config 1: An error while parsing the input file. 1: --> 2:22 | 2 | monitors.DP-1 = } | ^--- | = expected object, array, boolean, null, string, integer, float, or input 1: ``` 2. I have implemented a custom deserializer for the config which gives you *some* idea of what's invalid. Until Serde improves its untagged enum error handling, this is as good as we'll get. ``` 2022-12-12T23:08:49.796950Z ERROR ironbar: 0: Invalid Corn config 1: An error occurred when deserializing: 0: An invalid config was found. The following errors were encountered: 1: single-bar (b): unknown variant `dfjdjf`, expected one of `clock`, `mpd`, `tray`, `workspaces`, `sys_info`, `launcher`, `script`, `focused`, `custom` 2: multi-bar (c): invalid type: map, expected a sequence Location: src/config.rs:67 Note: Both the single-bar (type b / error 1) and multi-bar (type c / error 2) config variants were tried. You can likely ignore whichever of these is not relevant to you. Suggestion: Please see https://github.com/JakeStanger/ironbar/wiki/configuration-guide#2-pick-your-use-case for more info on the above ```` ``` 2022-12-12T23:12:45.282254Z ERROR ironbar: 0: Invalid Corn config 1: An error occurred when deserializing: Expected array, found 'String("dkfdfkd")' ``` As for the [last example](https://github.com/JakeStanger/ironbar/issues/39#issuecomment-1330692243), I've no idea since this is coming from the bar itself rather than loading the config. Hopefully the refactoring I merged in yesterday I got it. Hoping to merge in the above in the next couple of days.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
JakeStanger/ironbar#27
No description provided.