Skip to content

feat: populate Config attribute in hook params#924

Draft
gustavogama-cll wants to merge 1 commit intomainfrom
ggama/fix/add-pipeline-config-to-hook-params
Draft

feat: populate Config attribute in hook params#924
gustavogama-cll wants to merge 1 commit intomainfrom
ggama/fix/add-pipeline-config-to-hook-params

Conversation

@gustavogama-cll
Copy link
Copy Markdown
Contributor

No description provided.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 11, 2026

⚠️ No Changeset found

Latest commit: cbc56a6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds changeset configuration (Config) to hook parameter structs and proposal metadata so post-proposal hooks can receive the same config that was used when generating/applying a changeset.

Changes:

  • Populate Config on pre/post hooks during ChangesetsRegistry.Apply and on post-proposal hooks via RunProposalHooks.
  • Persist changeset config into MCMS timelock proposal metadata and plumb it through the mcms hooks command.
  • Add/adjust tests to assert config propagation and handle large numeric values.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
engine/cld/commands/pipeline/run.go Writes changeset config into proposal metadata alongside input.
engine/cld/commands/pipeline/run_test.go Updates expectations for proposal metadata (config) and large numeric input.
engine/cld/commands/mcms/cmd_run_hooks.go Decodes config from proposal metadata and passes it into proposal hooks.
engine/cld/commands/mcms/cmd_run_hooks_test.go Validates proposal hooks receive/log the decoded config.
engine/cld/changeset/registry.go Populates hook params with Config and adds GetConfiguration.
engine/cld/changeset/registry_test.go Adds coverage for config propagation in hooks and GetConfiguration.
engine/cld/changeset/postprocess.go Ensures post-processed changesets forward configuration().
engine/cld/changeset/postprocess_test.go Tests configuration() forwarding through post-processing wrapper.
engine/cld/changeset/mcms.go Extends RunProposalHooks to accept and pass through config.
engine/cld/changeset/mcms_test.go Updates tests for new RunProposalHooks signature + config param.
engine/cld/changeset/hooks.go Adds Config field to PostProposalHookParams.
engine/cld/changeset/common.go Adds configuration() to internal changeset interface and impl.
engine/cld/changeset/common_test.go Tests configuration() behavior across config wiring modes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +220 to +223
changesetConfig, err := applySnapshot.registryEntry.changeset.configuration()
if err != nil {
return fdeployment.ChangesetOutput{}, fmt.Errorf("failed to get changeset configuration: %w", err)
}
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

Apply() now computes changesetConfig via changeset.configuration() before running hooks, but this ignores the WithInput(...) ApplyOption. When cfg.inputStr is set, the changeset execution uses applyWithInput(e, cfg.inputStr) (potentially using configProviderWithInput), while hooks will receive a config derived from the default provider (often DURABLE_PIPELINE_INPUT), so hook params can diverge from the actual config used for the apply. Consider deriving the hook Config from the same source as applyWithInput (e.g., add a configurationWithInput(inputStr string) method to internalChangeSet, or pass cfg.inputStr into configuration() and have ChangeSetImpl use configProviderWithInput when inputStr is non-empty).

Copilot uses AI. Check for mistakes.
func (r *ChangesetsRegistry) GetConfiguration(key string) (any, error) {
entry, ok := r.entries[key]
if !ok {
return ChangesetConfig{}, fmt.Errorf("changeset '%s' not found", key)
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

GetConfiguration returns ChangesetConfig{} when the key is not found, but the method’s return type is any and callers likely treat the value as the changeset’s configuration (which can be nil). Returning a ChangesetConfig struct here is misleading and inconsistent with the API intent; return nil (or a typed zero of the configuration type if you want a non-nil sentinel) alongside the error instead.

Suggested change
return ChangesetConfig{}, fmt.Errorf("changeset '%s' not found", key)
return nil, fmt.Errorf("changeset '%s' not found", key)

Copilot uses AI. Check for mistakes.
Comment on lines 218 to 241
@@ -221,13 +229,15 @@ func saveChangesetProposalMetadata(changesetName string, out fdeployment.Changes
}

proposal.Metadata["changesets"] = []struct {
ID string `json:"id"`
Name string `json:"name"`
Input json.RawMessage `json:"input"`
ID string `json:"id"`
Name string `json:"name"`
Input json.RawMessage `json:"input"`
Config any `json:"config"`
}{{
ID: id,
Name: changesetName,
Input: json.RawMessage(changesetInputJSON),
ID: id,
Name: changesetName,
Input: json.RawMessage(changesetInputJSON),
Config: changesetConfig,
}}
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

changesetConfig is stored into proposal metadata as any. If a changeset was configured via WithEnvInput/WithJSON with an any-typed payload, it can contain json.Number values (your codebase explicitly uses UseNumber() for this). json.Number marshals as a JSON string under json.MarshalIndent (used by jsonutils.WriteFile), so numeric config values will be persisted quoted and will not round-trip as numbers when loading the proposal later. To preserve numeric semantics, consider storing config as json.RawMessage (like input) and generating that raw JSON with a marshaller that emits json.Number as a number token (or normalizing json.Number to json.RawMessage(n.String()) recursively before writing).

Copilot uses AI. Check for mistakes.
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