core/config: a config file that exists but cannot be parsed must be an error, not skipped #147

Open
opened 2026-10-16 13:43:38 +02:00 by michael · 0 comments
Owner

Goal

A config file that exists but cannot be parsed must be an error, not
silently treated as "not present". Found while preparing the resource
catalog generator (DAW/daw-modul-berhtjan-core#13), which reads the
merged program/user/runtime config at install time.

Background

core/config.lua try_parse() returns nil both when a file does not exist
and when it exists but fails to parse. load() then merges whatever is
left. Checked with small config variants against core.config.load():

Case Result
all levels valid cfg loaded
program config unparsable, nothing else load() -> nil, "program config not found ... Run: make install-config". main.lua stops (9994), but the message is misleading: the file exists, and make install-config skips it ("already exists")
program config valid, user config unparsable silently ignored, no error; overrides in the user config are lost
program config unparsable, runtime config valid silently continues without the broken level

main.lua already stops when load() returns nil (9994) and when cfg.exit
is missing (9993); the cases above are the ones that get through or are
reported wrongly.

Scope

  • try_parse() distinguishes "file does not exist" (fine, level absent)
    from "file exists but cannot be read or parsed" (error, naming the
    file and the parser error as cause)
  • load() returns that error instead of merging the remaining levels
  • the misleading "program config not found" hint is only shown when the
    file really does not exist
  • core/config.lua errors as daw_error/v1 with resource_id (part of the
    fragjan error/i18n migration; may be done there)

Acceptance criteria

  • unparsable program, user or runtime config -> load() returns an
    error naming the file; nothing is merged around it
  • absent user config stays fine (level is optional)
  • tests for each case above, Lua 5.1 and 5.4

DAW/daw-modul-berhtjan-core#13 (the generator needs the merged config
and must not run with silently dropped levels)

## Goal A config file that exists but cannot be parsed must be an error, not silently treated as "not present". Found while preparing the resource catalog generator (DAW/daw-modul-berhtjan-core#13), which reads the merged program/user/runtime config at install time. ## Background core/config.lua try_parse() returns nil both when a file does not exist and when it exists but fails to parse. load() then merges whatever is left. Checked with small config variants against core.config.load(): | Case | Result | |---|---| | all levels valid | cfg loaded | | program config unparsable, nothing else | load() -> nil, "program config not found ... Run: make install-config". main.lua stops (9994), but the message is misleading: the file exists, and make install-config skips it ("already exists") | | program config valid, user config unparsable | silently ignored, no error; overrides in the user config are lost | | program config unparsable, runtime config valid | silently continues without the broken level | main.lua already stops when load() returns nil (9994) and when cfg.exit is missing (9993); the cases above are the ones that get through or are reported wrongly. ## Scope - try_parse() distinguishes "file does not exist" (fine, level absent) from "file exists but cannot be read or parsed" (error, naming the file and the parser error as cause) - load() returns that error instead of merging the remaining levels - the misleading "program config not found" hint is only shown when the file really does not exist - core/config.lua errors as daw_error/v1 with resource_id (part of the fragjan error/i18n migration; may be done there) ## Acceptance criteria - [ ] unparsable program, user or runtime config -> load() returns an error naming the file; nothing is merged around it - [ ] absent user config stays fine (level is optional) - [ ] tests for each case above, Lua 5.1 and 5.4 ## Related DAW/daw-modul-berhtjan-core#13 (the generator needs the merged config and must not run with silently dropped levels)
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
DAW/fragjan#147
No description provided.