FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat(config): warn on unknown keys by MD-Mushfiqur123 · Pull Request #1614 · floatpane/matcha · GitHub

feat(config): warn on unknown keys - #1614

Open
MD-Mushfiqur123 wants to merge 6 commits into
floatpane:release/v1from
MD-Mushfiqur123:feat/warn-unknown-config-keys
Open

feat(config): warn on unknown keys#1614
MD-Mushfiqur123 wants to merge 6 commits into
floatpane:release/v1from
MD-Mushfiqur123:feat/warn-unknown-config-keys

Conversation

MD-Mushfiqur123 commented Jun 23, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

What?

Emit a warning via log.Printf listing unrecognized config keys at startup, helping users catch typos in their config.json.

Why?

Typos in config keys are silently ignored. This change provides immediate feedback to the user.

How?

  • Added warnUnknownConfigKeys function that checks for unknown top-level and account-level config keys
  • Called it during LoadConfig after reading the file
  • Added test coverage

Closes #1521

floatpanebot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Hi @MD-Mushfiqur123! Please fix the following issues with your PR:

  • Title: Is too long (49 characters). The PR title must be strictly under 40 characters.
  • Body: Missing the ## What? or ## Why? headings required by the PR template.

floatpanebot added enhancement New feature or request area/config Configuration / settings size/M Diff: 51–200 lines labels Jun 23, 2026
MD-Mushfiqur123 force-pushed the feat/warn-unknown-config-keys branch from 476876d to 1fc1c46 Compare June 23, 2026 08:26

floatpanebot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Hi @MD-Mushfiqur123! Please fix the following issues with your PR:

  • Title: Is too long (49 characters). The PR title must be strictly under 40 characters.
  • Body: Missing the ## What? or ## Why? headings required by the PR template.

floatpanebot commented Jun 23, 2026
edited
Loading

Copy link
Copy Markdown
Member

Benchmark report — no significant change

Metrics worse: 0 · better: 0 (threshold: ±3%).

benchstat output
goos: linux
goarch: amd64
pkg: github.com/floatpane/matcha/backend
cpu: AMD EPYC 7763 64-Core Processor                
                           │   old.txt    │               new.txt                │
                           │    sec/op    │    sec/op      vs base               │
ParseSearchQuery_Simple-4    2.695µ ± 32%   2.683µ ± 215%        ~ (p=0.818 n=6)
ParseSearchQuery_Complex-4   7.055µ ± 29%   8.034µ ±  34%        ~ (p=0.699 n=6)
TokenizeSearchQuery-4        4.139µ ± 22%   5.682µ ±  46%        ~ (p=0.132 n=6)
geomean                      4.285µ         4.966µ         +15.89%

                           │  old.txt   │              new.txt               │
                           │    B/op    │    B/op     vs base                │
ParseSearchQuery_Simple-4    26.00 ± 0%   26.00 ± 0%       ~ (p=1.000 n=6) ¹
ParseSearchQuery_Complex-4   762.0 ± 0%   762.0 ± 0%       ~ (p=1.000 n=6) ¹
TokenizeSearchQuery-4        176.0 ± 0%   176.0 ± 3%       ~ (p=1.000 n=6)
geomean                      151.6        151.6       +0.00%
¹ all samples are equal

                           │  old.txt   │              new.txt               │
                           │ allocs/op  │ allocs/op   vs base                │
ParseSearchQuery_Simple-4    2.000 ± 0%   2.000 ± 0%       ~ (p=1.000 n=6) ¹
ParseSearchQuery_Complex-4   23.00 ± 0%   23.00 ± 0%       ~ (p=1.000 n=6) ¹
TokenizeSearchQuery-4        9.000 ± 0%   9.000 ± 0%       ~ (p=1.000 n=6) ¹
geomean                      7.453        7.453       +0.00%
¹ all samples are equal

pkg: github.com/floatpane/matcha/tui
                    │   old.txt    │               new.txt               │
                    │    sec/op    │    sec/op      vs base              │
LogPanelView-4        162.5µ ±  7%    176.0µ ± 13%       ~ (p=0.093 n=6)
SearchOverlayView-4   178.3µ ± 23%    180.0µ ±  4%       ~ (p=0.937 n=6)
InboxConstruction-4   967.4µ ± 14%   1085.1µ ± 20%       ~ (p=0.180 n=6)
geomean               303.7µ          325.1µ        +7.05%

                    │    old.txt    │               new.txt               │
                    │     B/op      │     B/op       vs base              │
LogPanelView-4        44.67Ki ± 51%   44.67Ki ±  0%       ~ (p=1.000 n=6)
SearchOverlayView-4   56.14Ki ± 41%   56.14Ki ± 41%       ~ (p=0.530 n=6)
InboxConstruction-4   874.2Ki ±  0%   874.3Ki ±  0%       ~ (p=0.485 n=6)
geomean               129.9Ki         129.9Ki        +0.00%

                    │   old.txt   │              new.txt              │
                    │  allocs/op  │  allocs/op   vs base              │
LogPanelView-4         714.0 ± 0%    714.0 ± 0%       ~ (p=1.000 n=6)
SearchOverlayView-4    926.0 ± 0%    926.0 ± 0%       ~ (p=1.000 n=6)
InboxConstruction-4   3.478k ± 0%   3.478k ± 0%       ~ (p=0.530 n=6)
geomean               1.320k        1.320k       +0.00%

auto-generated by benchmarks.yml

floatpanebot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Hi @MD-Mushfiqur123! Please fix the following issues with your PR:

  • Title: Is too long (49 characters). The PR title must be strictly under 40 characters.
  • Body: Missing the ## What? or ## Why? headings required by the PR template.

Copy link
Copy Markdown
Member

This feature should go to release/v1. Please, move the commit there, AND append other keys.

MD-Mushfiqur123 changed the title feat(config): warn on unknown keys in config file feat(config): warn on unknown config keys Jun 23, 2026

floatpanebot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Hi @MD-Mushfiqur123! Please fix the following issues with your PR:

  • Title: Is too long (41 characters). The PR title must be strictly under 40 characters.

MD-Mushfiqur123 changed the title feat(config): warn on unknown config keys feat(config): warn on unknown keys Jun 23, 2026
floatpanebot dismissed stale reviews from themself June 23, 2026 08:52

Formatting issues have been resolved. Thank you!

Copy link
Copy Markdown
Contributor Author

All CI checks are passing now. Could this please be reviewed/merged when you get a chance? Thanks!

Copy link
Copy Markdown
Member

@MD-Mushfiqur123 please, rebase this PR on release/v1 branch. You can checkout to release/v1, cherry-pick the commit, resolve the conflicts if needed and force push to this branch (please, note, that you need to change target on this PR, you need to edit the title and underneath change master to release/v1)

MD-Mushfiqur123 changed the base branch from master to release/v1 June 23, 2026 13:07
MD-Mushfiqur123 force-pushed the feat/warn-unknown-config-keys branch from abd2ce2 to 2f52179 Compare June 23, 2026 13:07
floatpanebot added the target/v1 PR targets the release/v1 branch directly label Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

@andrinoff Done! Rebased on release/v1 and updated the base branch. Thanks for the review!

andrinoff left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This is a very unreliable implementation, this will add 2 more lists that have to be configured each time, we need a new option. This should replicate the Account and Config structs

Comment thread config/config.go Outdated
Comment on lines +958 to +970
"accounts": true,
"disable_images": true,
"hide_tips": true,
"disable_notifications": true,
"enable_split_pane": true,
"enable_threaded": true,
"enable_detailed_dates": true,
"theme": true,
"mailing_lists": true,
"date_format": true,
"language": true,
"body_cache_threshold_mb": true,
"plugin_settings": true,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This is not full

Comment thread config/config.go Outdated
Comment on lines +974 to +1000
"id": true,
"name": true,
"email": true,
"password": true,
"service_provider": true,
"fetch_email": true,
"send_as_email": true,
"imap_server": true,
"imap_port": true,
"smtp_server": true,
"smtp_port": true,
"insecure": true,
"smime_cert": true,
"smime_key": true,
"smime_sign_by_default": true,
"pgp_public_key": true,
"pgp_private_key": true,
"pgp_key_source": true,
"pgp_pin": true,
"pgp_sign_by_default": true,
"auth_method": true,
"protocol": true,
"jmap_endpoint": true,
"pop3_server": true,
"pop3_port": true,
"catch_all": true,
"pass_cmd": true,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

this isnt full either

MD-Mushfiqur123 force-pushed the feat/warn-unknown-config-keys branch from 34e80b9 to 938c953 Compare June 24, 2026 00:57

Copy link
Copy Markdown
Contributor Author

@andrinoff Updated! Replaced the hardcoded key maps with reflection-based extraction from Config and Account struct tags. The valid keys are now derived automatically from the struct definitions.

Copy link
Copy Markdown
Contributor Author

@andrinoff The hardcoded key lists are now replaced with structJSONKeys using reflection on Config and Account struct tags. No more manual lists to maintain. Please re-review when you get a chance!

MD-Mushfiqur123 force-pushed the feat/warn-unknown-config-keys branch from 938c953 to f70f32e Compare June 24, 2026 05:33

Copy link
Copy Markdown
Contributor Author

@andrinoff Rebased on the latest release/v1 and the reflection-based approach is already in place. Could you please re-review when you get a chance?

andrinoff left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Make assertion tests, these ones test nothing. For the other issue there are several solution, one of them would be to mirror rawAccount struct instead (i am not sure if that is the cleanest solution.

Comment thread config/config_test.go
Comment on lines +715 to +730
func TestWarnUnknownConfigKeys(t *testing.T) {
tests := []struct {
name string
json string
}{
{"no unknown keys", `{"accounts": [{"name": "test", "email": "a@b.com", "service_provider": "gmail"}], "theme": "dark"}`},
{"empty object", `{}`},
{"invalid json", `not json`},
{"nested with unknown", `{"unknown_top": true, "accounts": [{"name": "test", "email": "a@b.com", "unknown_field": true}]}`},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
warnUnknownConfigKeys([]byte(tc.json))
})
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

1st of all, this test only tests, that the function will not fail, it doesnt test anything, use assertion

Comment thread config/config.go Outdated

func initKnownKeys() {
knownConfigKeys = structJSONKeys(Config{})
knownAccountKeys = structJSONKeys(Account{})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

due to Account struct having Password and PGPPin as json:-, they will most likely not pass the test if config.json has them (user can use it, it will be then migrated to OS-keyrings

MD-Mushfiqur123 force-pushed the feat/warn-unknown-config-keys branch from 4cea1cf to 386d16d Compare June 25, 2026 00:02

Copy link
Copy Markdown
Contributor Author

@andrinoff Updated based on your feedback:

  • Now uses diskConfig/rawAccountstructs for reflection (mirrors actual JSON keys, sopassword, pgp_pin`, etc. are recognized as valid)
  • Moved structs to package level to share with the key extraction logic
  • Tests now capture log output and assert on expected warnings

Please re-review when you get a chance!

floatpanebot added the size/L Diff: 201–800 lines label Jun 25, 2026
Emit a warning via log.Printf listing unrecognized config keys at startup.
This helps users catch typos in their config.json.

Closes floatpane#1521
Replace hardcoded knownConfigKeys and knownAccountKeys maps with
dynamic extraction from Config and Account struct tags via reflection.
This eliminates the maintenance burden of keeping the key lists in
sync with the struct definitions.
MD-Mushfiqur123 force-pushed the feat/warn-unknown-config-keys branch from 386d16d to 71f1f82 Compare June 25, 2026 00:23

Copy link
Copy Markdown
Member

Great! The logic now works as expected!

Now, there are 2 aspects of this:

The current implementation pushes the error to stderr, which will show only after the user quits matcha

I'd suggest add an error message via bubble-overlay for the user, as well as adding loglevel verbose print.

After that, i think we are good to merge.

floatpanebot added the stale No activity for extended period label Aug 10, 2026

Copy link
Copy Markdown
Member

This has had no activity for 45 days. It will be closed in 21 days unless updated. Comment or remove the stale label to keep it open.

floatpanebot removed the stale No activity for extended period label Aug 12, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Configuration / settings enhancement New feature or request size/L Diff: 201–800 lines size/M Diff: 51–200 lines target/v1 PR targets the release/v1 branch directly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FEAT: Warn on unknown keys in config file

3 participants


Back | FazBrowse Home | New Git URL