Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/agent/provision.go
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,7 @@ func ProvisionAgent(ctx context.Context, agentName string, templateName string,
TemplatePaths: templatePaths,
ProfileName: profileName,
Settings: settings,
ConfigDirPath: api.HarnessConfigPathFromContext(ctx),
})
if err != nil {
return "", "", nil, fmt.Errorf("failed to resolve harness for %q: %w", harnessConfigName, err)
Expand Down
1 change: 1 addition & 0 deletions pkg/agent/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ func (m *AgentManager) Start(ctx context.Context, opts api.StartOptions) (*api.A
TemplatePaths: resolveTemplatePaths,
ProfileName: profileName,
Settings: settings,
ConfigDirPath: opts.HarnessConfigPath,
})
if err != nil {
util.Debugf("harness.Resolve fell back to New(%q): %v", harnessName, err)
Expand Down
9 changes: 8 additions & 1 deletion pkg/harness/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type ResolveOptions struct {
TemplatePaths []string // optional template dirs (highest priority)
ProfileName string // active profile (for settings overlay)
Settings *config.VersionedSettings // optional settings overlay
ConfigDirPath string // explicit harness-config dir (Hub-hydrated path); takes priority over name-based lookup
}

// ResolvedHarness is the result of harness.Resolve. The selected
Expand Down Expand Up @@ -67,7 +68,13 @@ func Resolve(_ context.Context, opts ResolveOptions) (*ResolvedHarness, error) {
return nil, fmt.Errorf("harness.Resolve requires a name")
}

hcDir, hcErr := config.FindHarnessConfigDir(opts.Name, opts.ProjectPath, opts.TemplatePaths...)
var hcDir *config.HarnessConfigDir
var hcErr error
if opts.ConfigDirPath != "" {
hcDir, hcErr = config.LoadHarnessConfigDir(opts.ConfigDirPath)
} else {
hcDir, hcErr = config.FindHarnessConfigDir(opts.Name, opts.ProjectPath, opts.TemplatePaths...)
}
Comment on lines +71 to +77

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

If an explicit ConfigDirPath is provided but fails to load (e.g., due to a missing or malformed config.yaml), silently ignoring the error and falling back to a generic or built-in harness can lead to unexpected behavior and make debugging difficult. Since the path is explicitly provided, any failure to load it should be treated as a hard error.

	var hcDir *config.HarnessConfigDir
	var hcErr error
	if opts.ConfigDirPath != "" {
		hcDir, hcErr = config.LoadHarnessConfigDir(opts.ConfigDirPath)
		if hcErr != nil {
			return nil, fmt.Errorf("failed to load explicit harness config directory %q: %w", opts.ConfigDirPath, hcErr)
		}
	} else {
		hcDir, hcErr = config.FindHarnessConfigDir(opts.Name, opts.ProjectPath, opts.TemplatePaths...)
	}


entry := config.HarnessConfigEntry{Harness: opts.Name}
if hcDir != nil {
Expand Down
Loading