Skip to content

jf helm package fails to collect build-info when Chart.yaml and packaged chart archive are in different directories. - #501

Open
kumadee wants to merge 4 commits into
jfrog:mainfrom
kumadee:main
Open

jf helm package fails to collect build-info when Chart.yaml and packaged chart archive are in different directories.#501
kumadee wants to merge 4 commits into
jfrog:mainfrom
kumadee:main

Conversation

@kumadee

@kumadee kumadee commented Jul 7, 2026

Copy link
Copy Markdown
  • All tests passed. If this feature is not already covered by the tests, I added new tests.
  • All static analysis checks passed.
  • Appropriate label is added to auto generate release notes.
  • I used gofmt for formatting the code before submitting the pull request.
  • PR description is clear and concise, and it includes the proposed solution/fix.

Original issue was raised as a part of Jfrog support ticket 426969.

Here is the problem statement:
When jf helm package command is executed with multiple options contains different paths e.g. chart directory path, chart archive destination path, keyring path and all of these path are different, then the command fails as it expects a Chart.yaml in each of these directories.

In the below log the Chart.yaml is in ./target/my-app-chart and the my-app-384-SNAPSHOT.tgz is successfully created in ./target/helm. For some reason, the jf cli expects the Chart.yaml to be always in the same directory as the Chart.yaml.

$ /home/kumadee/git/dev/SCM/scms.Pipelinelibraries/jf helm package ./target/my-app-chart -d ./target/helm
08:53:39 [Debug] JFrog CLI version: 2.112.0
08:53:39 [Debug] OS/Arch: linux/amd64
08:53:39 [Debug] Trace ID for JFrog Platform logs: 6617edb913131a61
08:53:39 [Info] Running Helm  package .
Running alias script args: package ./target/my-app-chart -d target/helm/
08:53:39 [Debug] Sending HTTP GET request to: https://myartifactory.example.com/artifactory/api/system/version
08:53:39 [Debug] JFrog CLI version: 2.109.0
08:53:39 [Debug] OS/Arch: linux/amd64
08:53:39 [Debug] Trace ID for JFrog Platform logs: 893d29af54d911b0
08:53:39 [Info] Running Helm  package .
08:53:39 [Debug] Sending HTTP GET request to: https://myartifactory.example.com/artifactory/api/system/version
Successfully packaged chart and saved it to: target/helm/my-app-384-SNAPSHOT.tgz
08:53:39 [Debug] Artifactory response: 200 
08:53:39 [Debug] Artifactory Call Home: Sending info...
08:53:39 [Debug] Sending HTTP POST request to: https://myartifactory.example.com/artifactory/api/system/usage
08:53:39 [Debug] Sending HTTP POST request to: https://myartifactory.example.com/jfconnect/api/v1/backoffice/metrics/log
08:53:39 [Info] Collecting build info for executed helm package command
08:53:39 [Debug] Reading build general details from: /tmp/jfrog-kumadee/builds/2cdd5ec3b76db5669ce1c92bfe1d22492f77fc2409ab2c4c05655ef413006d81/partials
08:53:39 [Debug] Creating temp build file at: /tmp/jfrog-kumadee/builds/2cdd5ec3b76db5669ce1c92bfe1d22492f77fc2409ab2c4c05655ef413006d81
08:53:39 [Info] Build info saved locally. Use 'jf rt bp test-local-build 7-helm ' to publish it to Artifactory.
08:53:39 [Info] Trace ID for JFrog Platform logs: 893d29af54d911b0
08:53:39 [Error] failed to collect build info: failed to create Helm FlexPack: failed to load Chart.yaml: failed to read Chart.yaml: open /home/kumadee/git/dev/clear/my-app/k8s/target/helm/Chart.yaml: no such file or directory
08:53:39 [Debug] Artifactory response: 200 
08:53:39 [Debug] Artifactory Call Home: Sending info...
08:53:39 [Debug] Sending HTTP POST request to: https://myartifactory.example.com/artifactory/api/system/usage
08:53:39 [Debug] Sending HTTP POST request to: https://myartifactory.example.com/jfconnect/api/v1/backoffice/metrics/log
08:53:39 [Info] Trace ID for JFrog Platform logs: 6617edb913131a61
08:53:39 [Error] helm package failed: exit status 1

Proposed solution: Filter out the different paths given in the helm package CHART_DIR .... command. There can be only 1 chart directory in the command, which can be checked by the presence of Chart.yaml.

Summary by CodeRabbit

  • Bug Fixes
    • Improved Helm packaging to identify the correct chart directory using Chart.yaml, while ignoring unrelated paths.
    • Prevented duplicate build-info collection and updates when packaging charts.
    • Added clearer error reporting when no valid chart directory is found or when chart processing encounters an issue.
  • Tests
    • Expanded coverage for multiple packaging input formats, chart detection, missing charts, and build-info dependency details.

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@kumadee

kumadee commented Jul 7, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@kumadee

kumadee commented Jul 7, 2026

Copy link
Copy Markdown
Author

recheck

kumadee added a commit to kumadee/jfrog-cli that referenced this pull request Jul 7, 2026
kumadee added a commit to kumadee/jfrog-cli that referenced this pull request Jul 10, 2026
kumadee added a commit to kumadee/jfrog-cli that referenced this pull request Jul 10, 2026
@naveenku-jfrog naveenku-jfrog added the safe to test Approve running integration tests on a pull request label Jul 16, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Jul 16, 2026
@naveenku-jfrog

Copy link
Copy Markdown
Collaborator

PR's branch is out of sync and all cli integration tests are failing, please fix these first.

@kumadee

kumadee commented Jul 16, 2026

Copy link
Copy Markdown
Author

I have rebased the PR branch with the default branch. Unit tests are passing on my local. Waiting for the integration tests to be executed on CI.

@kumadee

kumadee commented Jul 22, 2026

Copy link
Copy Markdown
Author

@naveenku-jfrog Could you please let me know what else do I need to do so that this PR can move forward? Do I need to ask JFrog support to give the reviewers any additional details?

kumadee added a commit to kumadee/jfrog-cli that referenced this pull request Jul 23, 2026
kumadee added a commit to kumadee/jfrog-cli that referenced this pull request Jul 28, 2026
@kumadee

kumadee commented Jul 28, 2026

Copy link
Copy Markdown
Author

@naveenku-jfrog @bhanurp @udaykb2 Dear reviewers, Could you please let me know what else do I need to do so that this PR can move forward?

Comment thread artifactory/commands/helm/package.go Outdated
func isChartDir(dir string) bool {
chartPath := filepath.Join(dir, flexpack.ChartYaml)
_, err := os.Stat(chartPath)
return !errors.Is(err, os.ErrNotExist)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This treats any non-ErrNotExist error (permission denied, I/O error, etc.) as “is a chart dir,” which can send FlexPack down a bad path. Prefer existence success only:

_, err := os.Stat(chartPath)
return err == nil

Then errors can be dropped.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Updated as suggested. Added corresponding unit tests.

Comment thread artifactory/commands/helm/package.go Outdated
removeDuplicateDependencies(buildInfoOld)
err = saveBuildInfo(buildInfoOld, buildName, buildNumber, project)
if err != nil {
return fmt.Errorf("failed to save build info")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fmt.Errorf("failed to save build info") still drops the underlying error; should use %w.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated as suggested.

Comment on lines +46 to +49
name: "chart path with destination flag",
args: func(chartPath, destination string) []string {
return []string{chartPath, "--destination", destination}
},

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug report used short -d. Add a case:

return []string{chartPath, "-d", destination}

Missing cases:
No chart among paths → expect "no valid Helm chart directory found...".
Direct unit tests for isChartDir (exists / missing / non-dir path).
Optional: destination dir that exists but has no Chart.yaml (regression for the ticket).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the test case as per bug report. Added missing test cases.

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 16bc3a08-8b31-46b3-9173-988c5ae24edf

📥 Commits

Reviewing files that changed from the base of the PR and between 3a9a184 and b404379.

📒 Files selected for processing (2)
  • artifactory/commands/helm/package.go
  • artifactory/commands/helm/package_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • artifactory/commands/helm/package.go

📝 Walkthrough

Walkthrough

Changes

Helm packaging now detects one directory containing Chart.yaml, returns ErrNoChartDirFound when none is found, and collects build info once. Tests cover packaging options, chart detection, dependency archives, and build-info contents.

Helm package flow

Layer / File(s) Summary
Chart detection and error contract
artifactory/commands/helm/package.go, artifactory/commands/helm/package_test.go
Resolves input paths, detects Chart.yaml, returns ErrNoChartDirFound, and tests valid and invalid paths.
Single-pass build-info processing
artifactory/commands/helm/package.go, artifactory/commands/helm/package_test.go
Collects and saves build info once, updates dependencies, wraps save errors, and validates dependency identifiers and SHA256 values.
Packaging scenarios and fixtures
artifactory/commands/helm/package_test.go
Tests path and flag forms, signing and dependency options, and creates chart and packaged subchart fixtures.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLIArguments
  participant handlePackageCommand
  participant isChartDir
  participant BuildInfoCollection
  participant BuildInfo
  CLIArguments->>handlePackageCommand: provide chart and option paths
  handlePackageCommand->>isChartDir: resolve and inspect paths
  isChartDir-->>handlePackageCommand: return selected chart directory
  handlePackageCommand->>BuildInfoCollection: collect build info once
  BuildInfoCollection-->>handlePackageCommand: return module and dependencies
  handlePackageCommand->>BuildInfo: update and save build info
  BuildInfo-->>handlePackageCommand: return result or wrapped error
Loading

Suggested reviewers: agrasth, bhanurp

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main fix for build-info collection when the chart and archive use different directories.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
artifactory/commands/helm/package_test.go (1)

289-295: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert dependency uniqueness.

The map hides duplicate dependency IDs, so this helper passes even if duplicate removal regresses.

Proposed test assertion
  for _, dep := range module.Dependencies {
    depIds[dep.Id] = true
    require.NotEmpty(t, dep.Sha256)
  }
+ require.Len(t, depIds, len(module.Dependencies), "Expected unique dependencies")
  require.True(t, depIds["subchart-a:0.1.0"])
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@artifactory/commands/helm/package_test.go` around lines 289 - 295, Update the
dependency assertions in the package test to verify uniqueness explicitly rather
than relying only on the depIds map. Assert that the number of collected
dependency IDs matches the expected unique dependency count, while retaining the
existing checks for subchart-a and subchart-b.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@artifactory/commands/helm/package_test.go`:
- Around line 289-295: Update the dependency assertions in the package test to
verify uniqueness explicitly rather than relying only on the depIds map. Assert
that the number of collected dependency IDs matches the expected unique
dependency count, while retaining the existing checks for subchart-a and
subchart-b.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d6b5b2bf-25af-420d-a6b7-7a65719f1aef

📥 Commits

Reviewing files that changed from the base of the PR and between 2227ac7 and 6a24ad5.

📒 Files selected for processing (2)
  • artifactory/commands/helm/package.go
  • artifactory/commands/helm/package_test.go

@kumadee
kumadee requested a review from naveenku-jfrog July 30, 2026 10:41
kumadee added a commit to kumadee/jfrog-cli that referenced this pull request Jul 30, 2026
kumadee added 4 commits August 4, 2026 09:17
…n helm chart archive

When `helm package /path/to/chart --destination /tmp/target` is
executed, we need to filter out directories which doesn't contain
Chart.yaml.
@kumadee

kumadee commented Aug 4, 2026

Copy link
Copy Markdown
Author

@naveenku-jfrog Could you please re-review the changes?

kumadee added a commit to kumadee/jfrog-cli that referenced this pull request Aug 4, 2026
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.

2 participants