Generator: emit resolveBaseURL when URL fields contain placeholders When an API…
- User
Generator: emit resolveBaseURL when URL fields contain placeholders
When an API specification contains
{PLACEHOLDER}tokens in URL-bearing fields, the generator must infer those placeholder names intoEndpointTemplateVarsbefore validation and generation so the generated client includesresolveBaseURLsupport.Inspect
BaseURL,BasePath,GraphQLEndpointPath, tier base URLs, and resource, endpoint, and subresource base URLs. Preserve existing explicit entries and their order, append each newly discovered placeholder once, and use deterministic ordering when traversing maps. Generation from a templated base URL must produce a buildable client containing the URL resolver.Evaluation contract
Generator.Newmust invoke placeholder inference before it returns, so callers can observe the inferredEndpointTemplateVarsimmediately and later validation/generation uses the same populated specification. Scan every documented URL-bearing field, preserve explicit variables and their order, append each inferred name once, and make map-backed traversal deterministic.Interface
Type: Function Name: InferEndpointTemplateVarsFromBaseURLs Path: internal/spec/spec.go Input: (no parameters) Output: (no return value; mutates receiver's EndpointTemplateVars) Description: Scans the receiver's BaseURL, BasePath, GraphQLEndpointPath, tier BaseURLs, and resource/endpoint/subresource BaseURLs for
{PLACEHOLDER}tokens and appends any newly discovered placeholders to EndpointTemplateVars, preserving existing explicit entries and their order. Call after loading or modifying any URL-bearing field but before validation or code generation. - Assistant
I’ll implement this as a systemic Printing Press generator change, add focused inference/order tests plus a generated-client build check if the existing harness supports it, then run formatting, targeted tests, goldens, and the full Go suite. I’ll keep issue/claim operations out of scope because this task explicitly prohibits external access.
- Assistant
rgisn’t installed in this workspace, so I’m falling back to scopedgrep/findsearches and continuing with the same inspection. - Assistant
The existing resolver is conditionally emitted whenever
EndpointTemplateVarsis non-empty; the defect is that placeholders in several URL fields never populate that slice. I’ve confirmed the right fix is centralized inference onAPISpec, called both during internal spec loading (before validation) and explicitly byGenerator.New, with sorted traversal for every map-backed tier/resource layer. - Assistant
The focused tests are running now; the generator case exercises the full emitted module and compiles it, while the spec case verifies explicit-order preservation, deduplication, invalid-token rejection, recursive coverage, and deterministic tier/resource/endpoint traversal.
- Assistant
The focused tests pass, including a real generated module build from a templated base URL with no explicit template-variable declaration. I also corrected the test placement after noticing the first insertion landed inside an existing generated-test fixture string; the repository test now executes normally. Next I’m running the required repo formatting, golden verification, build, and full suite.
- Assistant
Formatting and diff checks are clean. Golden verification cannot start because the repository harness requires
jq, which is absent from this environment; I confirmed there is no local executable to use. I’m continuing with the mandated relative-path binary build and full Go test suite, using single-package build parallelism because the environment previously exhausted process slots during compilation. - Assistant
The repository binary build has succeeded and the full suite is progressing package-by-package without failures so far. The suite is slower under constrained parallelism, but this avoids the earlier compiler process-exhaustion error.
- Assistant
The full suite exposed an environment limit rather than code failures: many existing parallel tests launch nested
go build/go vetprocesses, and those subprocesses ignored the outer-p=1, exhausting the process quota. The changed-package tests and generated-client build still pass. After this run exits, I’ll retry withGOFLAGS=-p=1inherited by nested Go commands so the suite can execute within the container limit. - Assistant
The constrained retry is behaving as intended: nested compiler processes are no longer hitting the quota. It is currently in the repository’s heavier CLI/generator integration packages; no failure has been reported on this retry.
- Assistant
The constrained full run has now passed the entire
internal/clipackage (the first package that failed solely from process exhaustion). It is continuing through the generator integration suite under the same inherited limit. - Assistant
The generator suite is still active and quiet, which is expected because many tests compile isolated generated CLIs and only print a package result at completion. The process remains healthy; I’m letting the required full run finish rather than substituting narrower coverage.
- Assistant
The full generator integration package remains within its normal long-running phase under serialized nested builds. No errors or resource warnings have appeared in the constrained run, and the process is continuing to make CPU-time progress.
- Assistant
The constrained run eliminated process-exhaustion failures, but two unrelated baseline packages still report failures: an existing pipeline filesystem-error assertion and at least one generator test whose detailed name was lost in the package’s very large warning stream. I’m isolating the first generator failure with fail-fast output filtering to verify whether it is related to this change.
- Assistant
Fail-fast isolation is still running through tests that began in parallel before any failure was encountered; output is intentionally filtered to failure lines. The focused feature tests remain independently green, and no failure line has appeared yet.
- Assistant
The isolated generator failure is confirmed unrelated: its required
govulncheckgate rejects the installed Go 1.26.4 standard library for GO-2026-5856 (fixed in Go 1.26.5). The pipeline failure also reproduces alone without touching this code. I’m doing a final source/diff audit and rerunning the complete affected packages (excluding that known vulnerability-gate integration test only if necessary) before handoff. - Assistant
The affected generator package is now being rerun in full with only
TestGenerateWithNoAuthskipped, since that test is guaranteed to fail on the installed vulnerable Go patch release. The temporary repository binary created for verification has also been removed; only the four intended source/test files remain modified. - Assistant
The complete affected packages are green: all
internal/spectests pass, and allinternal/generatortests pass when excluding only the known Go-standard-library vulnerability gate. I’m performing the final clean-worktree/diff check now; no additional implementation changes are needed.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.