Describe the bug
Symptoms
When calling RegisterOrReplace more than once for the same pipeline step identifier, an exception in the following format is thrown:
System.Exception: Step registration with id '<step-identifier>' is already registered for '<step-identifier>'.
Who's affected
Anyone with a use case for calling RegisterOrReplace on the same pipeline step more than once. One such use case is described in this Discourse post.
Root cause
The call to RegisterOrReplace adds a RegisterOrReplaceStep to a list that is processed when the pipeline model is built without any checking for duplicates. As a result, the same logic that prevents more than one Register step with the same StepId throws an exception when duplicate steps are found.
Confirmed workarounds
None
Original bug report
From the following Discourse post:
https://discuss.particular.net/t/multiple-registerorreplace-calls-for-same-pipeline-step-identifier/4468
We have multiple pipeline steps that are added depending on certain criteria. It might happen that the exact same behavior has already been registered (because of some shared logic). Therefore, I wanted to use the RegisterOrReplace hook. My understanding was that it would either replace an existing step of the same identifier, or do its actual registration.
When I do the following:
pipeline.RegisterOrReplace(
stepId: nameof(DemoPipelineStep),
behavior: new DemoPipelineStep(),
description: "test");
// somewhere later on
pipeline.RegisterOrReplace(
stepId: nameof(DemoPipelineStep),
behavior: new DemoPipelineStep(),
description: "test");
This crashes with System.Exception: Step registration with id 'DemoPipelineStep' is already registered for 'Demo.DemoPipelineStep'.
It only works if one of the two registration steps uses the Register hook, the actual order of registration has no impact.
My understanding of RegisterOrReplace would have been that it simply does not matter how often I call RegisterOrReplace with the same step identifier, the last registration that is called would win and do the replacement. Is this intended behavior?
Steps to reproduce
Register or replace the same pipeline step using the RegisterOrReplace method more than once, and try to run the project.
Relevant log output
Additional Information
None
Describe the bug
Symptoms
When calling
RegisterOrReplacemore than once for the same pipeline step identifier, an exception in the following format is thrown:Who's affected
Anyone with a use case for calling
RegisterOrReplaceon the same pipeline step more than once. One such use case is described in this Discourse post.Root cause
The call to
RegisterOrReplaceadds aRegisterOrReplaceStepto a list that is processed when the pipeline model is built without any checking for duplicates. As a result, the same logic that prevents more than oneRegisterstep with the sameStepIdthrows an exception when duplicate steps are found.Confirmed workarounds
None
Original bug report
From the following Discourse post:
https://discuss.particular.net/t/multiple-registerorreplace-calls-for-same-pipeline-step-identifier/4468
We have multiple pipeline steps that are added depending on certain criteria. It might happen that the exact same behavior has already been registered (because of some shared logic). Therefore, I wanted to use the
RegisterOrReplacehook. My understanding was that it would either replace an existing step of the same identifier, or do its actual registration.When I do the following:
This crashes with
System.Exception: Step registration with id 'DemoPipelineStep' is already registered for 'Demo.DemoPipelineStep'.It only works if one of the two registration steps uses the
Registerhook, the actual order of registration has no impact.My understanding of
RegisterOrReplacewould have been that it simply does not matter how often I callRegisterOrReplacewith the same step identifier, the last registration that is called would win and do the replacement. Is this intended behavior?Steps to reproduce
Register or replace the same pipeline step using the
RegisterOrReplacemethod more than once, and try to run the project.Relevant log output
Additional Information
None