Skip to content

Fix examples/config-sample.json and cover the example configs with a test - #4709

Open
VictorZaca wants to merge 3 commits into
archlinux:masterfrom
VictorZaca:fix-config-sample
Open

Fix examples/config-sample.json and cover the example configs with a test#4709
VictorZaca wants to merge 3 commits into
archlinux:masterfrom
VictorZaca:fix-config-sample

Conversation

@VictorZaca

Copy link
Copy Markdown

examples/config-sample.json cannot be parsed by the current config format. Running
archinstall --config examples/config-sample.json on a machine that actually has the configured
device raises before the installer starts.

Five separate problems, all in the sample rather than in the parser:

  1. Every partition is missing dev_path. DiskLayoutConfiguration.parse_arg indexes it
    directly (partition['dev_path']), so it raises KeyError: 'dev_path'.
  2. "sector_size": null in every size and start. Size.parse_args hands it to
    SectorSize.parse_args, which indexes arg['value'], so it raises
    TypeError: 'NoneType' object is not subscriptable.
  3. /home uses "unit": "Percent", which is not a member of Unit, so it raises
    KeyError: 'Percent'.
  4. / and /home overlap. / starts at 513 MiB and is 20 GiB long, so it ends at 20993 MiB,
    but /home starts at 20 GiB (20480 MiB), so it raises ValueError: Partitions overlap.
  5. "gfx_driver": "All open-source (default)" no longer matches any GfxDriver value; the
    enum is All open-source.

Fixes: dev_path is set to null on each partition, every sector_size becomes an explicit 512 B
object, /home becomes a fixed 10 GiB starting at 20993 MiB, and gfx_driver is corrected. The
layout the sample describes is otherwise unchanged, apart from /home no longer claiming a
percentage the format does not support.

Test

The reason this went unnoticed is that partition entries are only parsed when the configured device
is present on the machine: device_handler.get_device() returns None and the entry is skipped
with a silent continue, so no CI runner ever reaches that code. The added coverage works around
that:

  • test_example_config_parsing runs examples/config-sample.json and examples/creds-sample.json
    through ArchConfigHandler, which catches everything outside the disk section (item 5 above, and
    any future drift in the other sections).
  • test_example_config_partitions reads the partition entries straight from the JSON and asserts
    the invariants the parser would enforce: dev_path present, sizes parseable through
    Size.parse_args, first partition at no less than 1 MiB, and no overlap between consecutive
    partitions (items 1 to 4).

Reverting either change to the sample makes the corresponding test fail.

The sample config has not been valid since the 2023 disk layout rework
and currently fails to parse, so the file the README points users at
cannot be used:

- sector_size was null, but SectorSize became a required object
- partitions were missing the dev_path key, which the parser reads
- the /home size used the Percent unit, which no longer exists
- /home started at 20 GiB while / ended at 20993 MiB, overlapping it
- gfx_driver kept the old "All open-source (default)" value

Sizes and keys now mirror what the installer itself writes when saving
a configuration.
Nothing in the test suite or CI reads examples/, which is how the sample
config could stay broken for years while every other config surface kept
working. Parse both example files through ArchConfigHandler, and check
the partition entries directly since the parser only reaches them when
the configured device exists on the machine, which is never true in CI.
@VictorZaca
VictorZaca requested a review from Torxed as a code owner August 12, 2026 03:36
Copilot AI lite review requested due to automatic review settings August 12, 2026 03:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the bundled example configuration (examples/config-sample.json) so it conforms to the current config schema and no longer crashes when used, and adds tests to prevent future drift between example configs and the parser expectations.

Changes:

  • Fix examples/config-sample.json to include required partition fields (dev_path, sector_size objects), correct units/layout, and update gfx_driver to a valid enum value.
  • Add fixtures for the example config/creds files.
  • Add tests to parse the example config/creds via ArchConfigHandler and to validate disk partition invariants directly from the JSON.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
tests/test_args.py Adds tests that parse the example config/creds and validate partition invariants using Size.parse_args.
tests/conftest.py Adds session-scoped fixtures pointing to examples/config-sample.json and examples/creds-sample.json.
examples/config-sample.json Fixes sample config fields/values to match current parsing expectations (partition schema, sector sizes, non-overlap, gfx driver).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/test_args.py Outdated
The loops in test_example_config_partitions would not execute if
device_modifications or a device's partitions were empty, so the test
could pass while checking nothing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants