Skip to content

Octopus Germany: Fix Access Validation Infinite Loop#29433

Draft
r0oland wants to merge 3 commits intoevcc-io:masterfrom
r0oland:master
Draft

Octopus Germany: Fix Access Validation Infinite Loop#29433
r0oland wants to merge 3 commits intoevcc-io:masterfrom
r0oland:master

Conversation

@r0oland
Copy link
Copy Markdown
Contributor

@r0oland r0oland commented Apr 27, 2026

fix issue #29041

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-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.

Hey - I've found 1 issue, and left some high level feedback:

  • Relying on strings.Contains against error messages (especially the generic "Invalid data") is brittle; if possible, prefer checking concrete error types or well-defined error codes from ActiveAgreement so authentication failures can be identified more robustly.
  • Instead of using the authErr side flag, consider returning a wrapped sentinel error (e.g., ErrAuthFailed) from the backoff closure and then branching on errors.Is(err, ErrAuthFailed) after Retry so the control flow is clearer and less stateful.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Relying on `strings.Contains` against error messages (especially the generic `"Invalid data"`) is brittle; if possible, prefer checking concrete error types or well-defined error codes from `ActiveAgreement` so authentication failures can be identified more robustly.
- Instead of using the `authErr` side flag, consider returning a wrapped sentinel error (e.g., `ErrAuthFailed`) from the backoff closure and then branching on `errors.Is(err, ErrAuthFailed)` after `Retry` so the control flow is clearer and less stateful.

## Individual Comments

### Comment 1
<location path="tariff/octopusde.go" line_range="98-100" />
<code_context>
 		if err := backoff.Retry(func() error {
 			agr, err := t.gqlClient.ActiveAgreement()
 			if err != nil {
+				// Check for authentication errors and mark them as permanent
+				errMsg := err.Error()
+				if strings.Contains(errMsg, "authentication failed") || strings.Contains(errMsg, "Invalid data") {
+					authErr = true
+					return backoff.Permanent(err)
</code_context>
<issue_to_address>
**issue (bug_risk):** String-based auth error detection is brittle and may misclassify errors.

Relying on `err.Error()` substrings like "authentication failed" or a generic "Invalid data" makes this logic fragile and easy to break if messages change or collide with other errors. Where possible, use a typed error (e.g. `var ErrAuth`), a client error code, or another stable discriminator instead of message text to avoid misclassifying auth failures.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread tariff/octopusde.go Outdated
Co-authored-by: Copilot <copilot@github.com>
@naltatis
Copy link
Copy Markdown
Member

Hi @r0oland. Please pick descriptive PR title.

@naltatis naltatis added the tariffs Specific tariff support label Apr 27, 2026
@r0oland r0oland changed the title fix issue #29041 Fix Octopus Germany Access Validation Infinite Loop Apr 27, 2026
@naltatis naltatis changed the title Fix Octopus Germany Access Validation Infinite Loop Octopus Germany: Fix Access Validation Infinite Loop Apr 27, 2026
Comment thread tariff/octopusde.go

// Exit immediately on authentication errors instead of retrying
if errors.Is(err, ErrAuthFailed) {
t.log.ERROR.Printf("authentication failed - configuration error: %v", err)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what does "configuration error" mean here?

Comment thread tariff/octopusde.go
// isAuthError checks if an error indicates an authentication failure.
// It inspects error messages from the GraphQL client which typically contain
// "authentication failed" when credentials are invalid or missing.
func isAuthError(err error) bool {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
func isAuthError(err error) bool {
func (t *OctopusDe) isAuthError(err error) bool {

Comment thread tariff/octopusde.go
Comment on lines +145 to +146
errMsg := err.Error()
return strings.Contains(errMsg, "authentication failed")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
errMsg := err.Error()
return strings.Contains(errMsg, "authentication failed")
return strings.Contains(err.Error(), "authentication failed")

Comment thread tariff/octopusde.go
}, bo()); err != nil {
once.Do(func() { done <- err })

// Exit immediately on authentication errors instead of retrying
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is already after the retry. Just test for permanent error here and return if permanent?

Comment thread tariff/octopusde.go Outdated
@andig andig marked this pull request as draft April 27, 2026 08:47
Co-authored-by: andig <cpuidle@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tariffs Specific tariff support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants