Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@bmfrosty
Copy link

@bmfrosty bmfrosty commented Sep 18, 2025

Important

Update SHiFT client to handle CSRF tokens, manual redirects, and reflect API discontinuation.

  • Behavior:
    • Update Login() in client.go to handle CSRF tokens and improve error handling for login failures.
    • Modify RedeemShiftCode() in shift.go to return an error message indicating the discontinuation of the 2K Borderlands API.
    • Assume common platforms for SHiFT codes in GetCodePlatforms() and GetShiftPlatforms() in shift.go.
  • HTTP Client:
    • Add CheckRedirect function in NewHttpClient() in client.go to handle redirects manually.
    • Update headers in NewHttpClient() to mimic a real browser.
  • Error Handling:
    • Improve error messages in getResponse() in client.go for nil responses.
    • Enhance error handling in NewBl3Client() in client.go for reading and parsing config.json.

This description was created by Ellipsis for 87425f8. You can customize this summary. It will automatically update as commits are pushed.

@semanticdiff-com
Copy link

semanticdiff-com bot commented Sep 18, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  shift.go  9% smaller
  client.go  6% smaller
  .gitignore Unsupported file format
  config.json  0% smaller

@sonarqubecloud
Copy link

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Caution

Changes requested ❌

Reviewed everything up to 87425f8 in 2 minutes and 8 seconds. Click for details.
  • Reviewed 383 lines of code in 2 files
  • Skipped 2 files when reviewing.
  • Skipped posting 5 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. client.go:55
  • Draft comment:
    Avoid double deferring Close; let the caller manage response.Body closing.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
2. client.go:35
  • Draft comment:
    Consider setting a timeout on the http.Client to avoid hanging requests.
  • Reason this comment was not posted:
    Comment was on unchanged code.
3. shift.go:84
  • Draft comment:
    Reuse the Bl3Client's HTTP client in GetFullShiftCodeList instead of creating a new one.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
4. shift.go:94
  • Draft comment:
    Avoid using 'json' as a variable name to prevent shadowing the encoding/json package.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
5. client.go:221
  • Draft comment:
    The error message "SHiFT login service is temporarily unavailable (503)..." uses an inconsistent capitalization compared to the rest of the code (e.g. "shift.gearboxsoftware.com"). Consider using consistent capitalization (e.g., "SHIFT" or "shift") for clarity.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 0% vs. threshold = 50% This is a very minor stylistic suggestion about capitalization in an error message. SHiFT appears to be a brand name and may have official capitalization. The inconsistency doesn't impact functionality or code quality. This seems like the kind of nitpicky comment we should avoid. The comment could be valid if there's a strong style guide requirement for consistent capitalization. The current mixed capitalization could be slightly confusing to users. Brand names often have specific capitalization that differs from normal text. This is a user-facing error message where the exact capitalization of SHiFT is not critical to understanding. Delete this comment as it's too minor and focuses on non-functional aspects of an error message string.

Workflow ID: wflow_9dy29EacmEw5bxYl

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

// Extract session cookie from response
cookies := loginRes.Header.Values("Set-Cookie")
for _, cookie := range cookies {
if len(cookie) >= 12 && cookie[:12] == "_session_id=" {
Copy link

Choose a reason for hiding this comment

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

Use strings.HasPrefix for cookie prefix check instead of manual slicing.

Suggested change
if len(cookie) >= 12 && cookie[:12] == "_session_id=" {
if strings.HasPrefix(cookie, "_session_id=") {

// If it's a redirect to somewhere else, it's likely successful
if location != "" {
// Extract session cookie from response
cookies := loginRes.Header.Values("Set-Cookie")
Copy link

Choose a reason for hiding this comment

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

Refactor duplicate session cookie extraction logic into a helper function.

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.

1 participant