Skip to content
This repository was archived by the owner on Aug 17, 2025. It is now read-only.

chore: make it more difficult to construct invalid schema "root" objects#5349

Merged
alecthomas merged 3 commits intomainfrom
aat/schema-builder
May 5, 2025
Merged

chore: make it more difficult to construct invalid schema "root" objects#5349
alecthomas merged 3 commits intomainfrom
aat/schema-builder

Conversation

@alecthomas
Copy link
Copy Markdown
Collaborator

@alecthomas alecthomas commented May 5, 2025

Where "root" objects are Schema, Realm and Module.

This works by:

  1. Enabling linting for non-exhaustive manual construction of these types.
  2. Adding builders that validate on build.

Migrating existing usages to the builders was incredibly fiddly, so instead I've opted to rely on the incremental linting to catch future issues.

All cases can be discovered with:

golangci-lint run --enable-only exhaustruct

@alecthomas alecthomas mentioned this pull request May 5, 2025
@alecthomas alecthomas force-pushed the aat/schema-builder branch from 38f176a to 34153ec Compare May 5, 2025 07:46
alecthomas added 2 commits May 5, 2025 17:46
Where "root" objects are Schema, Realm and Module.

This works by:

1. Enabling linting for non-exhaustive manual construction of these types.
2. Adding builders that validate on build.
It is too big of a task, the linter will let us do it incrementally.
@alecthomas alecthomas force-pushed the aat/schema-builder branch from 34153ec to b0aa33b Compare May 5, 2025 07:46
@alecthomas alecthomas force-pushed the aat/schema-builder branch from b0aa33b to 691abbd Compare May 5, 2025 07:57
@alecthomas alecthomas marked this pull request as ready for review May 5, 2025 08:05
@alecthomas alecthomas requested a review from a team as a code owner May 5, 2025 08:05
@alecthomas alecthomas requested review from stuartwdouglas and removed request for a team May 5, 2025 08:05
@alecthomas alecthomas enabled auto-merge (squash) May 5, 2025 08:06
@alecthomas alecthomas merged commit 1114d9f into main May 5, 2025
76 checks passed
@alecthomas alecthomas deleted the aat/schema-builder branch May 5, 2025 08:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant