Conversation
This comment was marked as outdated.
This comment was marked as outdated.
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- The
maxPowerfield is effectively unused (only referenced in commented code incurtail); either wire it up viaSetMaxPoweror remove the parameter/field to avoid confusion. Runusestime.Tickwithout any way to stop the goroutine, which can leak a ticker and run forever; consider usingtime.NewTickerwith a stop mechanism (e.g., context cancellation) to allow clean shutdown.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `maxPower` field is effectively unused (only referenced in commented code in `curtail`); either wire it up via `SetMaxPower` or remove the parameter/field to avoid confusion.
- `Run` uses `time.Tick` without any way to stop the goroutine, which can leak a ticker and run forever; consider using `time.NewTicker` with a stop mechanism (e.g., context cancellation) to allow clean shutdown.
## Individual Comments
### Comment 1
<location> `hems/fnn/fnn-3.go:46-53` </location>
<code_context>
+ return nil, errors.New("hems requires load management- please configure root circuit")
+ }
+
+ // register LPP circuit if not already registered
+ lpp, err := shared.GetOrCreateCircuit("lpp", "fnn-3")
+ if err != nil {
+ return nil, err
+ }
+
+ // wrap old root with new pc parent
+ if err := root.Wrap(lpp); err != nil {
+ return nil, err
+ }
</code_context>
<issue_to_address>
**issue (bug_risk):** Avoid performing irreversible side effects (wrapping root circuit) before all dependent getters are successfully created
If `cc.S1.BoolGetter`, `cc.S2.BoolGetter`, or `cc.W3.BoolGetter` fails, this function returns an error after `root.Wrap(lpp)` and `site.SetCircuit(lpp)` have already changed global state, leaving a partially configured system despite `NewFromConfig` failing. Please reorder so all getters are constructed and configuration validated before wrapping the root and calling `site.SetCircuit`, or add compensating logic to roll back those side effects on error.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Comment on lines
+46
to
+53
| // register LPP circuit if not already registered | ||
| lpp, err := shared.GetOrCreateCircuit("lpp", "fnn-3") | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| // wrap old root with new pc parent | ||
| if err := root.Wrap(lpp); err != nil { |
Contributor
There was a problem hiding this comment.
issue (bug_risk): Avoid performing irreversible side effects (wrapping root circuit) before all dependent getters are successfully created
If cc.S1.BoolGetter, cc.S2.BoolGetter, or cc.W3.BoolGetter fails, this function returns an error after root.Wrap(lpp) and site.SetCircuit(lpp) have already changed global state, leaving a partially configured system despite NewFromConfig failing. Please reorder so all getters are constructed and configuration validated before wrapping the root and calling site.SetCircuit, or add compensating logic to roll back those side effects on error.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on #25887