Codegen: clear stale models on regen + fetch timeouts#70
Merged
Conversation
Delete the generator-owned subpackages (tables/, enums/) before writing so a table/enum dropped from the schema doesn't leave an orphan file — critical for autoSync (regenerates every build). Cleanup is scoped to those subpackages, so hand-written code in the package is untouched; a new invariant test asserts every generated file lands under a cleaned dir. Add 30s connect / 60s request timeouts to SchemaFetcher so a stalled fetch fails fast instead of hanging the compile.
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two robustness fixes from a codegen audit.
Stale-file cleanup (matters most for autoSync)
Before writing, the CLI and Gradle task delete the generator-owned subpackages (
tables/,enums/) under the target package. A table/enum dropped from the schema no longer leaves an orphan.ktthat compiles against something that no longer exists. Cleanup is scoped to those subpackages viaSupabaseModelGenerator.generatedSubpackages, so hand-written code elsewhere in the package is safe. A new invariant test asserts every generated file lands under a cleaned subpackage (so cleanup can never miss a model kind).Fetch timeouts
SchemaFetchernow sets 30s connect / 60s request timeouts, so a stalled connection fails the build with a clear error instead of hanging the compile pipeline forever.Both codegen modules build green (tests + detekt + spotless). Lands under Unreleased.