Skip to content

Conversation

@gearnode
Copy link
Contributor

@gearnode gearnode commented Dec 17, 2025

This is preparatory in order to change the load balancer configuration and keep the the end-user IP address available on the request (required to e-signature, cookie consent, etc.).

I've use the most maintain library. I'm not a big fan of the code of the lib tbh if we got issue with it I will write our own implementation.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

2 issues found across 4 files

Prompt for AI agents (all 2 issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="pkg/probod/probod.go">

<violation number="1" location="pkg/probod/probod.go:586">
P3: Missing `span.RecordError(err)` before returning the error. Other error returns in this function follow the pattern of recording the error to the span for tracing purposes.</violation>

<violation number="2" location="pkg/probod/probod.go:594">
P2: The second `defer listener.Close()` is unnecessary and causes a double-close. When `proxyproto.Listener` is closed, it also closes the underlying `net.Listener`. The original defer (line 580) already handles closing the wrapped listener. Remove this defer to avoid closing the underlying listener twice.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

ReadHeaderTimeout: 10 * time.Second,
Policy: policy,
}
defer listener.Close()
Copy link

@cubic-dev-ai cubic-dev-ai bot Dec 17, 2025

Choose a reason for hiding this comment

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

P2: The second defer listener.Close() is unnecessary and causes a double-close. When proxyproto.Listener is closed, it also closes the underlying net.Listener. The original defer (line 580) already handles closing the wrapped listener. Remove this defer to avoid closing the underlying listener twice.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At pkg/probod/probod.go, line 594:

<comment>The second `defer listener.Close()` is unnecessary and causes a double-close. When `proxyproto.Listener` is closed, it also closes the underlying `net.Listener`. The original defer (line 580) already handles closing the wrapped listener. Remove this defer to avoid closing the underlying listener twice.</comment>

<file context>
@@ -578,6 +580,22 @@ func (impl *Implm) runApiServer(
+			ReadHeaderTimeout: 10 * time.Second,
+			Policy:            policy,
+		}
+		defer listener.Close()
+
+		l.Info(&quot;using proxy protocol&quot;, log.String(&quot;trusted-proxies&quot;, strings.Join(impl.cfg.Api.ProxyProtocol.TrustedProxies, &quot;, &quot;)))
</file context>
Fix with Cubic

if len(impl.cfg.Api.ProxyProtocol.TrustedProxies) > 0 {
policy, err := proxyproto.StrictWhiteListPolicy(impl.cfg.Api.ProxyProtocol.TrustedProxies)
if err != nil {
return fmt.Errorf("cannot create proxy protocol policy: %w", err)
Copy link

@cubic-dev-ai cubic-dev-ai bot Dec 17, 2025

Choose a reason for hiding this comment

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

P3: Missing span.RecordError(err) before returning the error. Other error returns in this function follow the pattern of recording the error to the span for tracing purposes.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At pkg/probod/probod.go, line 586:

<comment>Missing `span.RecordError(err)` before returning the error. Other error returns in this function follow the pattern of recording the error to the span for tracing purposes.</comment>

<file context>
@@ -578,6 +580,22 @@ func (impl *Implm) runApiServer(
+	if len(impl.cfg.Api.ProxyProtocol.TrustedProxies) &gt; 0 {
+		policy, err := proxyproto.StrictWhiteListPolicy(impl.cfg.Api.ProxyProtocol.TrustedProxies)
+		if err != nil {
+			return fmt.Errorf(&quot;cannot create proxy protocol policy: %w&quot;, err)
+		}
+
</file context>
Suggested change
return fmt.Errorf("cannot create proxy protocol policy: %w", err)
span.RecordError(err)
return fmt.Errorf("cannot create proxy protocol policy: %w", err)
Fix with Cubic

Copy link
Contributor

@SachaProbo SachaProbo left a comment

Choose a reason for hiding this comment

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

LGTM

Signed-off-by: Bryan Frimin <[email protected]>
@gearnode gearnode force-pushed the add-proxy-protocol-support branch from 56b8cd8 to 0bd2b11 Compare January 8, 2026 14:26
@gearnode
Copy link
Contributor Author

gearnode commented Jan 8, 2026

@cubic-dev-ai please review

@cubic-dev-ai
Copy link

cubic-dev-ai bot commented Jan 8, 2026

@cubic-dev-ai please review

@gearnode I have started the AI code review. It will take a few minutes to complete.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 4 files

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.

3 participants