Skip to content

Bug | repo-server-api render method not handling refs correctly #401

@dominik-th

Description

@dominik-th

Describe the bug

Hello! I've noticed the repo-server-api renderer doesn't properly handle cross source references for Helm values when a source contains path and ref at the same time.

This is supposed to work and already does in the other renderers:

...
  sources:
    - ref: values
      repoURL: https://github.com/dominik-th/argocd-diff-preview-bug.git
      targetRevision: HEAD
      path: manifests
    - chart: cert-manager
      helm:
        valueFiles:
          - $values/values.yaml
      repoURL: https://charts.jetstack.io
      targetRevision: v1.20.1

This however does work with repo-server-api renderer:

...
  sources:
    - repoURL: https://github.com/dominik-th/argocd-diff-preview-bug.git
      targetRevision: HEAD
      path: manifests
    - ref: values
      repoURL: https://github.com/dominik-th/argocd-diff-preview-bug.git
      targetRevision: HEAD
    - chart: cert-manager
      helm:
        valueFiles:
          - $values/values.yaml
      repoURL: https://charts.jetstack.io
      targetRevision: v1.20.1

Standard output (with --debug flag)

...
Rendering application source via repo server (App: "demo [b|app.yaml]") (multiSource: true) (remoteChart: true) (sourceIndex: 1) (streamDir: )
Rendering application source via repo server (App: "demo [t|app.yaml]") (multiSource: true) (remoteChart: true) (sourceIndex: 1) (streamDir: )
❌ Failed to render application via repo server: error="failed to render app demo [b|app.yaml]: repo server returned error for content source 1: rpc error: code = Unknown desc = source referenced \"$values\", but no source has a 'ref' field defined"
❌ Failed to render application via repo server: error="failed to render app demo [t|app.yaml]: repo server returned error for content source 1: rpc error: code = Unknown desc = source referenced \"$values\", but no source has a 'ref' field defined"
Stopping port forward to Argo CD repo server...
❌ Failed to extract resources

Application causing problems (if applicable)

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: demo
  namespace: argocd
spec:
  destination:
    namespace: demo
    server: https://kubernetes.default.svc
  project: default
  sources:
    - ref: values
      repoURL: https://github.com/dominik-th/argocd-diff-preview-bug.git
      targetRevision: HEAD
      path: manifests
    - chart: cert-manager
      helm:
        valueFiles:
          - $values/values.yaml
      repoURL: https://charts.jetstack.io
      targetRevision: v1.20.1

Parameters

✨ Running with:
✨ - local-cluster-tool: kind
✨ - cluster-name: argocd-diff-preview
✨ - render-method: repo-server-api
✨ - base-branch: main
✨ - target-branch: refs/pull/1/merge
✨ - secrets-folder: ./secrets
✨ - output-folder: ./output
✨ - argocd-namespace: argocd
✨ - repo: dominik-th/argocd-diff-preview-bug
✨ - timeout: 180 seconds
✨ - debug: true - This is slower because it will do more checks
✨ - files-changed: <auto-detected>
✨ --- Fail on applications with invalid watch-pattern annotation
✨ --- Include applications with no watch-pattern annotation

Your pipeline (if applicable)

---
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Argo CD Diff Preview

on:
  pull_request:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write
    steps:
      - uses: actions/checkout@v4
        with:
          path: pull-request
      - uses: actions/checkout@v4
        with:
          ref: main
          path: main
      - name: Generate Diff
        run: |
          docker run \
            --network=host \
            -v /var/run/docker.sock:/var/run/docker.sock \
            -v $(pwd)/main:/base-branch \
            -v $(pwd)/pull-request:/target-branch \
            -v $(pwd)/output:/output \
            -e TARGET_BRANCH=refs/pull/${{ github.event.number }}/merge \
            -e REPO=${{ github.repository }} \
            dagandersen/argocd-diff-preview:v0.2.2 \
            --render-method=repo-server-api \
            --debug
      - name: Post diff as comment
        run: |
          gh pr comment ${{ github.event.number }} --repo ${{ github.repository }} --body-file output/diff.md --edit-last || \
          gh pr comment ${{ github.event.number }} --repo ${{ github.repository }} --body-file output/diff.md
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions