Skip to content

fix(ego-lint): check ALL schema IDs for settings-schema match#154

Open
ZviBaratz wants to merge 1 commit intomainfrom
fix/multi-schema-id-matches
Open

fix(ego-lint): check ALL schema IDs for settings-schema match#154
ZviBaratz wants to merge 1 commit intomainfrom
fix/multi-schema-id-matches

Conversation

@ZviBaratz
Copy link
Copy Markdown
Owner

Problem

When gschema.xml contains multiple <schema> elements (e.g. a main schema plus a .keybindings sub-schema), the previous code extracted only the first <schema id=...> attribute. If a sub-schema appeared first — as in PaperWM, where org.gnome.shell.extensions.paperwm.keybindings precedes the main org.gnome.shell.extensions.paperwm schema — schema/id-matches and schema/filename-convention both produced false-positive FAILs even though the correct schema was present.

Root Cause

extract_schema_id() used | head -1, so it always returned the first <schema id=...> attribute regardless of order. The schema/id-matches check then compared that first ID against settings-schema, and the schema/filename-convention check expected the file to be named after that first ID.

Fix

  • Add extract_all_schema_ids() — returns all <schema id=...> values from a file
  • Refactor extract_schema_id() to use it (single-schema case is unchanged)
  • Add schema_id_in_file(file, id) — returns 0 if the target ID is in any schema element
  • schema/id-matches: pass if settings-schema is found in any <schema> element (not just the first)
  • schema/filename-convention: when settings-schema is defined in metadata.json, use it as the reference ID for the expected filename (instead of the first schema found)

Test Coverage

  • New multi-schema@test fixture reproduces the PaperWM layout: .keybindings sub-schema appears first, main schema second
  • 4 new assertions: both checks produce PASS (not FAIL) on multi-schema XML

Affected Extensions

  • PaperWM — primary case: 2 false-positive FAILs eliminated
  • Any extension using a single gschema.xml with sub-schemas (keybindings, overrides, etc.)

🤖 Generated with Claude Code

When gschema.xml contains multiple <schema> elements (e.g. a main schema
plus a .keybindings sub-schema), the previous code extracted only the
first <schema id=...> attribute. If a sub-schema appeared first (as in
PaperWM, where org.gnome.shell.extensions.paperwm.keybindings precedes
the main org.gnome.shell.extensions.paperwm schema), schema/id-matches
and schema/filename-convention both produced false-positive FAILs even
though the correct schema was present.

Changes:
- Extract all schema IDs via new extract_all_schema_ids() helper
- Refactor extract_schema_id() to use it (single-schema case unchanged)
- Add schema_id_in_file() to test membership across all <schema> elements
- schema/id-matches: pass if settings-schema is found in ANY schema element
- schema/filename-convention: use settings-schema as the reference ID when
  settings-schema is defined in metadata.json (not the first schema found)
- Add multi-schema@test fixture reproducing the PaperWM layout
- Add 4 assertions to run-tests.sh covering the new behaviour

Fixes false-positive FAILs on PaperWM and any extension that uses
sub-schemas (keybindings, overrides, etc.) in a single gschema.xml.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ZviBaratz ZviBaratz changed the title fix(check-schema): check ALL schema IDs for settings-schema match fix(ego-lint): check ALL schema IDs for settings-schema match Mar 28, 2026
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.

1 participant