Skip to content

Comments

Fix: Cleanup twitch_token.json when disconnecting Twitch platform#212

Open
Nebhay wants to merge 4 commits intospacedriveapp:mainfrom
Nebhay:fix/twitch-token-cleanup-on-disconnect
Open

Fix: Cleanup twitch_token.json when disconnecting Twitch platform#212
Nebhay wants to merge 4 commits intospacedriveapp:mainfrom
Nebhay:fix/twitch-token-cleanup-on-disconnect

Conversation

@Nebhay
Copy link
Contributor

@Nebhay Nebhay commented Feb 25, 2026

This change will prevent stale/invalid token issue if the user plans to reconnect twitch affter disconnecting

Previously, disconnecting Twitch would remove credentials from config.toml and shut down the adapter, but the token file at instance_dir/twitch_token.json was left behind. This adds cleanup of the token file during disconnect.

Note

Adds explicit cleanup of twitch_token.json file when the Twitch platform is disconnected. The change modifies disconnect_platform() in src/api/messaging.rs to remove the token file after adapter shutdown, preventing stale tokens from persisting on reconnection. Includes error handling with appropriate logging for both successful deletion and potential failures.

Written by Tembo for commit 72c80ab.

Previously, disconnecting Twitch would remove credentials from config.toml
and shut down the adapter, but the token file at instance_dir/twitch_token.json
was left behind. This adds cleanup of the token file during disconnect.
@coderabbitai
Copy link

coderabbitai bot commented Feb 25, 2026

Walkthrough

disconnect_platform now includes Twitch-specific cleanup: when platform == "twitch" it computes the instance directory and attempts to asynchronously remove twitch_token.json; success logs info, NotFound is ignored, other errors log a warning. The cleanup code was inserted twice within the function.

Changes

Cohort / File(s) Summary
Twitch disconnect cleanup
src/api/messaging.rs
Added Twitch token-file removal logic in disconnect_platform: compute instance_dir, call tokio::fs::remove_file on twitch_token.json, log info on success, ignore NotFound, warn on other errors. The same cleanup block was inserted in two locations (duplicated).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: cleanup of twitch_token.json during Twitch platform disconnection, which directly relates to the file modification in src/api/messaging.rs.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description check ✅ Passed The pull request description clearly explains the purpose of the changes: cleaning up the twitch_token.json file when disconnecting Twitch to prevent stale token issues on reconnection.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Co-authored-by: tembo[bot] <208362400+tembo[bot]@users.noreply.github.com>
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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/api/messaging.rs`:
- Around line 249-252: Run rustfmt (cargo fmt --all) to fix the formatting
around the new match block; specifically reformat the match on
tokio::fs::remove_file(&token_path).await so the arms align and trailing
commas/parentheses are placed per rustfmt (ensure the Err arms and the final
closing paren are formatted like the other tracing! calls). You can also
manually adjust the spacing/line breaks in the match arms (the Ok/Err arms with
tracing::info! and tracing::warn!) to match rustfmt style, then re-run cargo fmt
to confirm the change.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bf9e05f and fd92898.

📒 Files selected for processing (1)
  • src/api/messaging.rs

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@Nebhay Nebhay marked this pull request as draft February 25, 2026 11:31
@Nebhay Nebhay marked this pull request as ready for review February 25, 2026 11:56
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