[bug]: config apply -f fails silently to parse configuration files using the configurations wrapper

Open Beginner friendly
#1,023 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
go
Domain
cli

Research direction

Start in cmd/harbor/root/configurations/apply.go and inspect how the YAML/JSON data is unmarshaled into models.Configurations. Reproduce the issue with harbor config apply -f config.yaml, then verify that the documented configurations wrapper is applied while the flat format remains compatible. Done means the command no longer reports no changes for nested configuration input.

Written by the indexing model from the issue text.

Description

bug status/in-progress

Description

The harbor config apply command fails silently when applying configuration files that nest configuration parameters under a top-level configurations: key (which is the format officially documented in the command synopsis). Instead of applying the configurations, the command unmarshals an empty configurations struct and outputs ✓ No changes detected. without applying any updates or returning an error.

Steps to Reproduce

  1. Create a configuration file named config.yaml with the following nested structure:
configurations:
  authmode: db_auth
  1. Run the command:
    harbor config apply -f config.yaml
  2. Observe the output:
    ✓ No changes detected.

Expected Behavior

The configuration options nested under the configurations key should be parsed successfully and applied/updated on the Harbor server.

Actual Behavior

The CLI silently ignores all fields nested under the configurations wrapper because the parser attempts to unmarshal the file directly into a flat *models.Configurations struct, which has no matching field for configurations.

Environment

  • OS: Windows / Linux / macOS
  • Tool version: Latest main (v0.9.0-dev)
  • Other relevant details: Go version 1.26.3

Additional Context

I have verified the root cause in cmd/harbor/root/configurations/apply.go. The parser directly unmarshals the YAML/JSON data into var configurations *models.Configurations without checking for the top-level wrapper first:

if err := yaml.Unmarshal(data, &configurations); err != nil {
    return fmt.Errorf("failed to parse YAML: %v", err)
}

This can be resolved by first attempting to parse the nested structure via a wrapper struct, and falling back to the flat format to preserve backward compatibility.

Dominant language
Go
Stars
163
Forks
212
Avg merge
1m
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from goharbor/harbor-cli

All issues in goharbor/harbor-cli

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.