-
Notifications
You must be signed in to change notification settings - Fork 24
join: follow proxy_to perimeters for contract redirect #202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
join: follow proxy_to perimeters for contract redirect #202
Conversation
Summary of ChangesHello @tuhalf, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the diode join contract synchronization mechanism by introducing robust support for Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
…r only print when the effective perimeter changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces support for proxy_to redirects for join contracts, a significant feature that allows for more flexible perimeter configurations. The implementation correctly handles redirect chain resolution, loop detection, and fallback mechanisms. The associated refactoring of property-fetching functions to be more generic is also well-executed. My review includes a couple of suggestions to improve maintainability and a minor efficiency tweak.
|
I tested it and it's ready to merge @dominicletz |
cmd/diode/join.go
Outdated
| if proxyTo == "" { | ||
| return chain, fetchErr | ||
| } | ||
| if idx := strings.IndexAny(proxyTo, " \t\r\n"); idx >= 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not strings.TrimSpace instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I think we should just call strings.TrimSpace once in getPropertyValuesAt when doing results[key] = strings.TrimSpace(value)
cmd/diode/join.go
Outdated
| proxyTo = strings.TrimSpace(props["proxy_to"]) | ||
| } | ||
| if proxyTo == "" { | ||
| return chain, fetchErr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The re-use of fetchErr is confusing because it's always nil. Better to just return nil here and in the following cases if that is the intention
dominicletz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added two small comments can ask copilot to fix.
|
@copilot update buildProxyToChain to not do it own trim implementation using Secondly buildProxyToChain remove the continuous use of |
|
@dominicletz I've opened a new pull request, #204, to work on those changes. Once the pull request is ready, I'll request review from you. |
…ProxyToChain (#204) * Initial plan * Refactor trim logic and fix error returns in buildProxyToChain Co-authored-by: dominicletz <2987674+dominicletz@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: dominicletz <2987674+dominicletz@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is being reviewed by Cursor Bugbot
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| } | ||
| if proxyTo == "" || strings.EqualFold(proxyTo, current) { | ||
| return chain, nil | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate empty string check creates unreachable dead code
The condition proxyTo == "" at line 271 is unreachable dead code because line 268 already checks if proxyTo == "" and returns at line 269. The second if statement only needs to check strings.EqualFold(proxyTo, current). This appears to be leftover code from refactoring the trim logic.
| if cfg != nil && cfg.Logger != nil { | ||
| cfg.Logger.Warn("proxy_to chain exceeded max depth (%d); stopping at %s", maxProxyToDepth, current) | ||
| } | ||
| return chain, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implicit nil return violates reviewer's explicit request (Bugbot Rules)
The reviewer explicitly requested that buildProxyToChain use nil as the explicit error return value instead of relying on the uninitialized named return variable err. At line 297, return chain, err returns the named return value which happens to be nil, but the reviewer asked for explicit nil to make the intent clear.
Resolve proxy_to redirect chains during diode join contract sync so “home” perimeters can proxy devices into operating perimeters (supports nested redirects). Apply k/vs from the effective (proxied) perimeter with loop detection and max depth, and fall back to the last working perimeter when a target has no readable properties. Refactor on-chain property fetch helpers to take an explicit contract address and print the proxy chain/effective perimeter when it changes.
Note
Follow proxy_to chains to select an effective perimeter (with loop detection, max depth, and fallback) and refactor contract property fetching to target explicit contracts, improving logging and trimming values.
proxy_tochain resolution (buildProxyToChain) with loop detection, address validation, and max depth, plus fallback selection (selectContractPropsWithFallback).contractSyncnow builds the chain, chooses the effective contract, applies its props, and prints proxy chain/effective perimeter when changed.getPropertyValuesAt(deviceAddr, contractAddr, keys)andfetchContractPropsFromContract(...)to fetch from an explicit contract.contractand result summaries.lastEffectiveContractandlastProxyToChainto control output.Written by Cursor Bugbot for commit 9b3b274. This will update automatically on new commits. Configure here.