Skip to content

Conversation

JanWerder
Copy link

@JanWerder JanWerder commented Apr 13, 2025

Changes

steam-deploy supports totp, but the script only checks for the test login. The actual upload command then doesn't utilize the neccessary +set_steam_guard_code parameter. This change adds that.

Checklist

  • Read the contribution guide and accept the code of conduct
  • Readme (updated or not needed)
  • Tests (added, updated or not needed)

Summary by CodeRabbit

  • New Features
    • Enhanced the login process for Steam deployments, allowing for dynamic authentication based on the validity of security credentials. Improved error handling ensures detailed logs and outputs are consistently available during login attempts.

Copy link

coderabbitai bot commented Apr 13, 2025

Walkthrough

The changes modify the steam_deploy.sh script to enhance the login process for Steam deployment. A conditional structure is introduced to check the validity of the steam_totp variable. Depending on its value, the script either includes the Steam Guard code in the login command or falls back to a simpler login method. Additionally, error handling is improved to ensure detailed logging occurs for both login attempts, maintaining the overall functionality of the script.

Changes

File Change Summary
steam_deploy.sh Introduces conditional checks for steam_totp validity; enhances error handling and logging for login attempts.

Sequence Diagram(s)

sequenceDiagram
    participant S as steam_deploy.sh
    participant C as steamcmd
    S->>S: Check steam_totp validity
    alt If steam_totp is valid
        S->>C: Execute steamcmd with Steam Guard code
    else
        S->>C: Execute steamcmd without Steam Guard code
    end
    C-->>S: Return login result
    S->>S: Log error details if login fails
Loading

Poem

I'm a playful rabbit in a code-filled lair,
Hopping through scripts with a cheerful flair.
Steam login's now flexible on its merry way,
Guard code twirls in only when it's okay.
With every build, I bounce and sing—
Cheers to changes that make our code spring!

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2d5b9ce and a0520f5.

📒 Files selected for processing (1)
  • steam_deploy.sh (1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.10.0)
steam_deploy.sh

[warning] 167-167: The surrounding quotes actually unquote this. Remove or escape them.

(SC2027)


[warning] 169-169: The surrounding quotes actually unquote this. Remove or escape them.

(SC2027)

steam_deploy.sh Outdated
Comment on lines 167 to 170
steam_login_args="+login "$steam_username""
if [ "$steam_totp" != "INVALID" ]; then
steam_login_args="+set_steam_guard_code "$steam_totp" $steam_login_args"
fi
Copy link

@coderabbitai coderabbitai bot Apr 13, 2025

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Fix quoting issues in dynamic login argument construction.

The concatenation of strings for steam_login_args on lines 167 and 169 is problematic. The embedded double quotes are not escaped, which causes the shell to unquote parts of the command and can lead to syntax errors or unexpected behavior. For example, the assignment in line 167:

steam_login_args="+login "$steam_username""

should properly escape the inner quotes. A suggested fix is:

-    steam_login_args="+login "$steam_username""
+    steam_login_args="+login \"$steam_username\""

Similarly, on line 169:

steam_login_args="+set_steam_guard_code "$steam_totp" $steam_login_args"

should be updated to:

-      steam_login_args="+set_steam_guard_code "$steam_totp" $steam_login_args"
+      steam_login_args="+set_steam_guard_code \"$steam_totp\" $steam_login_args"

This ensures that any spaces or special characters in the parameters are correctly managed and that the static analysis warnings (SC2027) are resolved.

🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 167-167: The surrounding quotes actually unquote this. Remove or escape them.

(SC2027)


[warning] 169-169: The surrounding quotes actually unquote this. Remove or escape them.

(SC2027)

Copy link
Author

Choose a reason for hiding this comment

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

Since every other parameter is passed the same way in this script, this should be fine

Copy link

Choose a reason for hiding this comment

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

@JanWerder You're absolutely right. I've checked the file and confirmed that this parameter passing style (using "$variable" without escaping the quotes) is consistently used throughout the script, such as in the test login command on line 97. Maintaining consistency in coding style across the codebase is important. Thanks for the clarification!

Copy link
Member

@webbertakken webbertakken left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
steam_deploy.sh (3)

135-160: Remove Obsolete Test Login Code

These lines contain a commented-out test login block that is no longer active. To improve clarity and reduce clutter, consider removing these unused code segments if they aren’t intended for future reference or debugging.


167-215: TOTP Login Branch: Validate and Refactor Error Handling

The updated TOTP branch now correctly includes the +set_steam_guard_code "$steam_totp" parameter in the upload command. However, there are two points worth noting:

  1. Variable Assignment Check:
    The static analysis warning (SC2154) indicates that steam_username is referenced but not assigned. Ensure that this variable is initialized (or provided via the environment) before usage to avoid runtime errors.
  2. Error Logging Duplication:
    The inline error-handling block within the command’s subshell is highly detailed but duplicated in the alternate branch. For maintainability and to avoid code duplication, consider extracting this error logging into a dedicated function, which can then be called from both branches.

Example diff for extracting error logging into a function:

+log_errors() {
+  echo ""
+  echo "#################################"
+  echo "#             Errors            #"
+  echo "#################################"
+  echo ""
+  echo "Listing current folder and rootpath"
+  echo ""
+  ls -alh
+  echo ""
+  ls -alh "$rootPath" || true
+  echo ""
+  echo "Listing logs folder:"
+  echo ""
+  ls -Ralph "$steamdir/logs/"
+  for f in "$steamdir"/logs/*; do
+    if [ -e "$f" ]; then
+      echo "######## $f"
+      cat "$f"
+      echo
+    fi
+  done
+  echo ""
+  echo "Displaying error log"
+  echo ""
+  cat "$steamdir/logs/stderr.txt"
+  echo ""
+  echo "Displaying bootstrapper log"
+  echo ""
+  cat "$steamdir/logs/bootstrap_log.txt"
+  echo ""
+  echo "#################################"
+  echo "#             Output            #"
+  echo "#################################"
+  echo ""
+  ls -Ralph BuildOutput
+  for f in BuildOutput/*.log; do
+    echo "######## $f"
+    cat "$f"
+    echo
+  done
+  exit 1
+}

Then, you could update the TOTP branch error handling like so:

-    steamcmd +set_steam_guard_code "$steam_totp" +login "$steam_username" +run_app_build "$manifest_path" +quit || (
-    ... # inline error logging block
-    exit 1
-  )
+    steamcmd +set_steam_guard_code "$steam_totp" +login "$steam_username" +run_app_build "$manifest_path" +quit || log_errors

Please verify that this refactor aligns with your design intentions.

🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 169-169: steam_username is referenced but not assigned.

(SC2154)


216-264: Standard Login Branch: Refactor Duplicate Error Handling

In the else branch for the standard login (lines 216–264), the error-handling code is essentially a duplicate of the one used in the TOTP branch. For better maintainability, consider refactoring this block into the same log_errors function suggested earlier. This will ensure consistency and simplify any future modifications to error reporting.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f1d90e7 and 00bae3a.

📒 Files selected for processing (1)
  • steam_deploy.sh (2 hunks)
🧰 Additional context used
🪛 Shellcheck (0.10.0)
steam_deploy.sh

[warning] 169-169: steam_username is referenced but not assigned.

(SC2154)

🔇 Additional comments (1)
steam_deploy.sh (1)

267-267: Ensure Robust Output Redirection

The final line appends the manifest path to the $GITHUB_OUTPUT file. Consider quoting the variable in the redirection to protect against potential word splitting or unexpected behavior if the variable contains spaces.

Example diff:

-echo "manifest=${manifest_path}" >> $GITHUB_OUTPUT
+echo "manifest=${manifest_path}" >> "$GITHUB_OUTPUT"

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
steam_deploy.sh (2)

170-218: TOTP Login Block: Correct Integration of TOTP with Room for Refactoring
This section improves the upload process by incorporating the TOTP parameter via +set_steam_guard_code "$steam_totp" when steam_totp is valid. The detailed error logging ensures issues are traceable on failure. However, the error-handling logic here is nearly identical to that in the standard login branch (lines 219-268). Consider refactoring the duplicated error-handling routines into a common helper function to adhere to DRY principles and ease future maintenance.


219-268: Standard Login Block: Consistency and DRY Opportunity
In this branch the login proceeds without the TOTP requirement, as expected. The error-handling approach (with extensive logging and exit on failure) replicates the structure used when TOTP is provided. Moving these common error handling routines to a shared function could reduce duplication and simplify future modifications.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 00bae3a and df21fc5.

📒 Files selected for processing (1)
  • steam_deploy.sh (3 hunks)
🧰 Additional context used
🪛 Shellcheck (0.10.0)
steam_deploy.sh

[warning] 143-143: steam_username is referenced but not assigned.

(SC2154)

🔇 Additional comments (2)
steam_deploy.sh (2)

135-162: Test Login Block: Validate Behavior and Environment Variables
This block triggers a test login when steam_totp equals "INVALID". Ensure that using the "INVALID" placeholder is intentional for test scenarios. Also, note that steam_username is referenced in the login command but is not explicitly assigned within this script; please verify that it is reliably set in the environment to avoid runtime errors.

🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 143-143: steam_username is referenced but not assigned.

(SC2154)


270-270: Manifest Output: Verify Environment Dependency
The command appending the manifest path to $GITHUB_OUTPUT assumes that this environment variable is set. Please verify that $GITHUB_OUTPUT is defined in the execution context to prevent potential issues in downstream processes.

@JanWerder
Copy link
Author

I've had a closer look and my inital commit didn't do the job proper. The problem seems to be that the verifying the TOTP with a test login takes too longl, so that the code cycles once the real upload step comes around. I've mitigated that by excluding the test-login step for TOTP.
@webbertakken What do you think?

Rycieos added a commit to monumentalco/steam-deploy that referenced this pull request Jul 18, 2025
When using TOTP, a password is required to login. While steamcmd is
perfectly fine with accepting the password as part of the username input
(separated with a space), the way this action is set up, the second
steamcmd invocation where the upload happens would then also use the
password, causing steamcmd to error because the password was provided
without the TOTP code.

Rather than use the TOTP code there again (as proposed in game-ci#86), add the
password in the test step (which will cache the credentials), and retain
it from the upload step.

In the configVdf case, the password will be empty, and steamcmd will
ignore it, keeping the previous mechanics.
@Rycieos Rycieos mentioned this pull request Jul 18, 2025
3 tasks
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.

2 participants