Skip to content

fix: enrichment redeploy loop and lowercase env name#60

Merged
TerrifiedBug merged 1 commit intomainfrom
fix/enrichment-redeploy-loop-v2
Mar 7, 2026
Merged

fix: enrichment redeploy loop and lowercase env name#60
TerrifiedBug merged 1 commit intomainfrom
fix/enrichment-redeploy-loop-v2

Conversation

@TerrifiedBug
Copy link
Copy Markdown
Owner

Summary

  • Fix infinite redeploy loop: pipeline.get was comparing YAML without enrichment transforms against deployed YAML that had them baked in — they could never match, so "pending deploy" always showed after any enrichment-enabled deploy.
  • Fix missing "pending deploy" on enrichment toggle: When toggling enrichMetadata ON, the editor didn't detect a configuration change because both comparison sides lacked enrichment.
  • Lowercase environment name in enrichment metadata (e.g. "production" instead of "Production").

Root cause

pipeline.get (editor/detail view) was missing the enrichment parameter in its call to generateVectorYaml(). The pipeline.list endpoint already had this fix, but pipeline.get was missed.

Changes

  • src/server/routers/pipeline.ts: Add name to environment select, version to latestVersion select, and pass enrichment to generateVectorYaml() in pipeline.get
  • src/lib/config-generator/yaml-generator.ts: Lowercase environment name in VRL enrichment source

Test plan

  • Enable enrichment on a deployed pipeline → editor shows "pending deploy"
  • Deploy with enrichment → editor no longer shows "pending deploy"
  • Verify enrichment metadata has lowercase environment name
  • Toggle enrichment OFF on deployed pipeline → editor shows "pending deploy"

…e env name

The pipeline.get endpoint was comparing YAML without enrichment transforms
against deployed YAML that had them baked in. This caused two bugs:

1. Toggling enrichMetadata ON didn't show "pending deploy" in the editor
   because both comparison sides lacked enrichment transforms.

2. After deploying with enrichment enabled, the editor always showed
   "pending deploy" because the non-enriched comparison YAML never matched
   the enriched deployed YAML, creating an infinite redeploy loop.

Fix: pass the same enrichment parameters to generateVectorYaml in
pipeline.get as pipeline.list already does, using the deployed version
number so the comparison is stable.

Also lowercase the environment name in enrichment metadata output.
@github-actions github-actions bot added the fix label Mar 7, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 7, 2026

Greptile Summary

This PR fixes two related bugs in the pipeline editor's "pending deploy" detection and corrects the casing of environment names in enrichment metadata.

  • Root cause fixed: pipeline.get was calling generateVectorYaml() without the enrichment parameter, so the YAML it generated for comparison never matched the deployed YAML (which had enrichment transforms baked in), causing a perpetual "pending deploy" state. The fix mirrors the already-correct pipeline.list implementation: select environment.name and latestVersion.version from the DB, construct an enrichment object when pipeline.enrichMetadata is true, and pass it through to generateVectorYaml().
  • Toggle detection fixed: Because pipeline.get now correctly reflects enrichMetadata state, toggling enrichment ON on a previously non-enriched pipeline is now detectable (the generated YAML diverges from the stored YAML).
  • Lowercase environment name: .toLowerCase() is applied inside generateVectorYaml() before the environment name is embedded in the VRL source. Pipelines that were deployed with an uppercase environment name will now show "pending deploy" until re-deployed with the corrected casing — this is the expected and documented behaviour.

Confidence Score: 5/5

  • Safe to merge — targeted bug fix with no logic regressions or security concerns.
  • The changes are minimal and tightly scoped. The new pipeline.get enrichment logic is a direct copy of the already-shipped pipeline.list pattern, making the two code paths consistent. The .toLowerCase() change is a one-liner with a clear, intentional side-effect (existing deployments with uppercase names will surface as needing a redeploy). No security-sensitive paths, no new data exposure, no missing middleware.
  • No files require special attention.

Important Files Changed

Filename Overview
src/server/routers/pipeline.ts Adds name to environment select and version to latestVersion select in pipeline.get, then constructs and passes an enrichment object to generateVectorYaml() — mirroring the already-correct pipeline.list implementation. Fixes the infinite "pending deploy" loop and the missed change detection on enrichment toggle.
src/lib/config-generator/yaml-generator.ts One-line change: applies .toLowerCase() to enrichment.environmentName before embedding it in the VRL source. Ensures the environment name is stored in lowercase (e.g. "production" vs "Production") in enrichment metadata. Pipelines previously deployed with an uppercase name will correctly show "pending deploy" until re-deployed.

Sequence Diagram

sequenceDiagram
    participant Client
    participant pipeline.get
    participant DB (Prisma)
    participant generateVectorYaml

    Client->>pipeline.get: query({ id })
    pipeline.get->>DB (Prisma): findUnique(pipeline)<br/>include environment { name } + nodes + edges
    DB (Prisma)-->>pipeline.get: pipeline (with environment.name)
    pipeline.get->>DB (Prisma): findFirst(latestVersion)<br/>select { configYaml, logLevel, version }
    DB (Prisma)-->>pipeline.get: latestVersion (with .version)

    alt enrichMetadata = true
        pipeline.get->>pipeline.get: enrichment = { environmentName, pipelineVersion }
    else enrichMetadata = false
        pipeline.get->>pipeline.get: enrichment = null
    end

    pipeline.get->>generateVectorYaml: (nodes, edges, globalConfig, enrichment)
    note over generateVectorYaml: if enrichment: inject remap transform<br/>with environmentName.toLowerCase()
    generateVectorYaml-->>pipeline.get: currentYaml

    pipeline.get->>pipeline.get: hasConfigChanges = (currentYaml !== latestVersion.configYaml)
    pipeline.get-->>Client: { ...pipeline, hasConfigChanges }
Loading

Last reviewed commit: d8af578

@TerrifiedBug TerrifiedBug merged commit c4351b2 into main Mar 7, 2026
12 checks passed
@TerrifiedBug TerrifiedBug deleted the fix/enrichment-redeploy-loop-v2 branch March 7, 2026 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant