fix: stabilization batch 5 — grpc scaffold, middleware, interfaces, elasticsearch, config port, swagger#61
Merged
Merged
Conversation
…aces, elasticsearch reads, config port, messages dry-run Continues the stabilization effort (follow-up to batch 4). Each fix reproduced against generated projects and verified with go build/go vet across all databases. - gRPC handler scaffold broke the whole module: the //go:build proto server imported a `pb` package that was never generated, so `go mod tidy`/`go vet` (which evaluate build-tagged files) attempted a remote module lookup and failed. Generate a build-tagged placeholder `pb` package so the import resolves locally; the default build still excludes it, and `-tags proto` compiles the scaffold against the stubs (delete the placeholder once protoc produces the real *.pb.go). - feature --middleware-types generated an internal/middleware package that was never imported: routes.go was written before the package existed, so it fell back to inline cors/logging duplicates and left the package orphaned. Generate the middleware package BEFORE the handlers so routes.go detects it and wires middleware.CORS/Logging from the package. - interfaces --handler/--all emitted non-compiling code: the gRPC request/response interfaces referenced a bare, undefined *User. Reference *domain.<Entity> and import the domain package. - Elasticsearch repository reads always returned empty: FindAll and FullTextSearch decoded (or ignored) the response and returned an untouched empty slice, and FindByID decoded the raw GET envelope instead of its "_source". Parse hits[]._source / _source into the domain types. - Generated .goca.yaml always recorded database.port: 5432 regardless of --database. Record the conventional port for the chosen database (mysql 3306, mongodb 27017, sqlserver 1433, elasticsearch 9200, sqlite 0). - goca messages --dry-run created empty internal/messages and internal/constants directories. Drop the unconditional os.MkdirAll; the file writers create parent dirs only when a file is actually written. - repository --implementation was a no-op (always regenerated the interface too, same as the default). It now emits only the implementation, mirroring --interface-only; feature wiring updated to request both layers explicitly. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The generated swaggo annotations referenced types that do not exist, so `swag init` would fail: - Get<Entity> used usecase.Get<Entity>Output, which is never generated — the handler returns the domain entity, so reference domain.<Entity>. - List<Entity>s used usecase.List<Entity>sOutput, but the use case returns usecase.List<Entity>Output (singular entity name). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Stabilization batch 5 — follow-up fixes from the batch-4 audit
Addresses the items documented (but not fixed) in #60. Each fix was reproduced against generated projects and verified with
go build/go vet. The full multi-DB matrix (init → feature --validation --middleware-types … → handler --type grpc) now builds + vets clean on all six databases —sqlite, postgres, mysql, postgres-json, sqlserver, mongodb(6/6).go test ./cmd/...is green.Fixed
//go:build protoserver imported apbpackage that was never generated;go mod tidy/go vetevaluate build-tagged files and attempted a remote module lookup, failing for the entire module. Now generate a build-tagged placeholderpbpackage so the import resolves locally — the default build still excludes it, and-tags protocompiles the scaffold against the stubs (the placeholder is deleted once protoc produces the real*.pb.go). Verified:go mod tidy, defaultgo build/go vet, andgo build -tags protoall succeed.feature --middleware-typesleft an orphaned package.routes.gowas generated before the middleware package existed, so it emitted inlinecors/loggingduplicates and never imported the package. Reordered so the middleware package is generated first;routes.gonow imports it and wiresmiddleware.CORS/middleware.Logging.interfaces --handler/--alldidn't compile (undefined: User). The gRPC request/response interfaces referenced a bare*User; they now return*domain.<Entity>and the package is imported. Verified theinterfacespackage builds.FindAll/FullTextSearchignored (or discarded) the response body and returned an untouched empty slice, andFindByIDdecoded the raw GET envelope instead of_source. Now parsehits[]._source/_sourceinto the domain types..goca.yamlalways recordeddatabase.port: 5432. Now records the conventional port for the chosen--database(mysql 3306, mongodb 27017, sqlserver 1433, elasticsearch 9200, sqlite/dynamodb 0).messages --dry-runcreated empty directories. Removed the unconditionalos.MkdirAll; the file writers create parent dirs only when a file is actually written.repository --implementationwas a no-op (it always regenerated the interface too, identical to the default). It now emits only the implementation, mirroring--interface-only;featureupdated to request both layers explicitly so its DI wiring still compiles.@Successannotations referenced non-existent types (swag initwould fail):Getusedusecase.Get<Entity>Output(never generated → nowdomain.<Entity>) andListusedusecase.List<Entity>sOutput(→ the realusecase.List<Entity>Output).Investigated — not bugs
middleware/config validate/config init/template show/doctor): all already return non-zero on error on current master (fixed in an earlier batch / stale audit).analyze --output json: already emits valid JSON on stdout (human output goes to stderr).--validation/--dto-validation: not dead — they toggle generation; the audit saw identical output only because the config defaults them on (config-driven default, same as--swagger).Remaining (genuinely larger — left for dedicated work)
init --template(minimal/rest-api/microservice/monolith/enterprise) still produces byte-identical Go code; only.goca.yamldiffers. Delivering distinct scaffolds (e.g. microservice gRPC, monolith web) is a feature, not a fix.goca template init+ edit) are still not consumed by generation — needs the template engine wired into the generators.interfaces --repository/--usecaseproduce standalone TDD interfaces that drift from the real generated implementations.test-integration --databasedoesn't affecthelpers.go(always imports all drivers).--cacheas the first feature is still orphaned (the new DI container is created with cache disabled) — needs fullredisClientscaffolding inNewContainer+main.go. (Batch 4 already made the incremental path compile-safe.)wiki/doc drift (Gin vs gorilla/mux, default DB, JWT version, file layout).Note: pre-existing test failures (not from this PR)
internal/testing/tests(TestEntityCommand,TestFeatureCommand,TestConfigCodeGeneration/DatabaseTypeMySQL) fail identically on master — stale hardcoded content expectations (e.g. expectingClient_id) that drifted from the generators across earlier batches. They are unrelated to this PR; worth a dedicated cleanup of the integration suite's expectations.🤖 Generated with Claude Code