Skip to content

GenerateTemplate RPC#8901

Draft
lovincyrus wants to merge 8 commits intomainfrom
cyrus/generate-template-rpc
Draft

GenerateTemplate RPC#8901
lovincyrus wants to merge 8 commits intomainfrom
cyrus/generate-template-rpc

Conversation

@lovincyrus
Copy link
Contributor

@lovincyrus lovincyrus commented Feb 21, 2026

This PR adds a GenerateTemplate RPC that moves connector/model YAML generation from the frontend to the backend.

  • New RuntimeService/GenerateTemplate endpoint accepts a driver name and form properties, returns a complete YAML blob and a map of environment variables with resolved names
  • Backend handles secret extraction (rendering values as {{ .env.VAR_NAME }} placeholders), DuckDB rewrites for file/object store drivers, SQL block formatting, and env var conflict resolution
  • EnvVarName field added to PropertySpec so each connector driver can declare its conventional env var name (e.g. AWS_ACCESS_KEY_ID) instead of relying on mechanical transforms
  • Frontend migrated: submitAddDataForm now calls generateTemplate() and writes the returned blob directly, replacing all client-side YAML generation logic
  • 54 tests covering YAML rendering, env var resolution, DuckDB rewrites, and edge cases

Checklist:

  • Covered by tests
  • Ran it and it works as intended
  • Reviewed the diff before requesting a review
  • Checked for unhandled edge cases
  • Linked the issues it closes
  • Checked if the docs need to be updated. If so, create a separate Linear DOCS issue
  • Intend to cherry-pick into the release branch
  • I'm proud of this work!

lovincyrus and others added 8 commits February 20, 2026 13:23
Adds a new GenerateTemplate RPC endpoint that serves as the single source
of truth for YAML format generation. Replaces frontend imperative YAML
builders with a centralized backend handler.

- Add EnvVarName field to PropertySpec for custom env var name mapping
- Populate EnvVarName values across 14 driver specs (S3, GCS, Azure,
  ClickHouse, Postgres, BigQuery, Snowflake, Redshift, MotherDuck,
  Athena, MySQL, Druid, Pinot, Salesforce)
- Define GenerateTemplate proto messages with validation annotations
- Implement handler: auth check, driver validation, property validation,
  DuckDB rewrite for object/file stores and sqlite
- Add comprehensive YAML renderers for connectors and models with precise
  formatting via yaml.Node tree construction
- Implement env var conflict resolution with _1, _2 suffix appending
- Add 54 passing test cases covering all drivers, error scenarios, and
  edge cases

Frontend migration to use this RPC will follow as a separate step.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace client-side YAML builders with backend RPC for single source of truth.

- New helper: `generateTemplate()` + `mergeEnvVars()` in generate-template.ts
- Updated submission paths: submitAddConnectorForm, submitAddSourceForm, saveConnectorAnyway
- Updated preview: computeYamlPreview now calls RPC (async, 150ms debounced)
- HTTPS connector path preserved (backend doesn't support headers array yet)
- Removed dead code: compileSourceYAML, prepareSourceFormData, maybeRewriteToDuckDb
- Backend now handles DuckDB rewrite and env var naming (conflict resolution)
- Tests: added mergeEnvVars (9 tests) and normalizeConnectorError (11 tests)
- Net: 234 lines removed (~27% reduction in submission/preview code)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ector headers

Add HTTPS headers support to the backend GenerateTemplate RPC, enabling removal
of all client-side YAML generation code. The HTTPS connector now uses the same
RPC path as all other connectors.

Backend changes:
- Add `headers` property to HTTPS driver ConfigProperties
- Implement header rendering with sensitive value extraction to .env
- Support Authorization header scheme prefixes (Bearer, Basic, Token, Bot)
- Use `connector.{driver}.{key}` naming convention for header env vars
- Add 4 comprehensive test cases for header handling

Frontend changes:
- Convert key-value UI arrays to maps before RPC submission
- Remove HTTPS-specific YAML preview and submission code
- All connectors now use GenerateTemplate RPC exclusively
- Remove 13 dead functions (compileConnectorYAML, updateDotEnvWithSecrets, etc)
- Consolidate env var naming to backend-only responsibility

Schema cleanup:
- Remove 30 dead `x-env-var-name` annotations (frontend no longer reads them)
- Single source of truth for env var names: backend PropertySpec.EnvVarName

Results:
- -1,317 lines of dead code removed
- +221 lines of backend implementation
- 2,055 frontend tests pass, 62 backend tests pass (4 new HTTPS tests)
The mapping from property Key to env var name doesn't follow a mechanical
pattern. Well-known names are shared across drivers (AWS_ACCESS_KEY_ID),
some add infixes (AZURE_STORAGE_*), and others diverge entirely
(GCS key_id -> GCP_ACCESS_KEY_ID). Each driver must specify explicitly.

Also remove personal docs from .gitignore.
- Fix gofmt alignment in connectors.go PropertySpec struct
- Remove unused connectorName param from renderDuckDBModelYAML
- Use const instead of let for newEnvBlob and connectorYamlBlob
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