mirror of
https://github.com/go-gitea/gitea.git
synced 2026-11-09 17:37:20 -06:00
fix(packages): return empty Chef dependencies instead of null (#40237)
Fixes #40230 Cookbooks without dependencies are served with `"dependencies": null` from the universe and version metadata endpoints. This happens because `omitempty` drops the empty map when the metadata is stored. Chef clients iterate over this value and Policyfile resolution crashes. Supermarket returns `{}` for these cookbooks, Gitea now does too. The fix checks whether dependencies are `nil` while building response, returns an empty map if true. This way cookbooks that are already stored are covered without a re-upload. Tested with the Chef integration test and `chef-cli install`. Assisted by Claude Code (claude-opus-5-5).
This commit is contained in:
@@ -345,6 +345,7 @@ nwIDAQAB
|
||||
assert.Equal(t, "opscode", info.LocationType)
|
||||
assert.Equal(t, setting.AppURL+root[1:], info.LocationPath)
|
||||
assert.Equal(t, fmt.Sprintf("%s%s/cookbooks/%s/versions/%s/download", setting.AppURL, root[1:], packageName, packageVersion), info.DownloadURL)
|
||||
assert.Equal(t, map[string]string{}, info.Dependencies)
|
||||
})
|
||||
|
||||
type listCase struct {
|
||||
@@ -463,6 +464,7 @@ nwIDAQAB
|
||||
assert.Equal(t, packageVersion, result.Version)
|
||||
assert.Equal(t, packageURL, result.Cookbook)
|
||||
assert.Equal(t, fmt.Sprintf("%s/versions/%s/download", packageURL, packageVersion), result.File)
|
||||
assert.Equal(t, map[string]string{}, result.Dependencies)
|
||||
})
|
||||
|
||||
t.Run("Delete", func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user