Fix Slack auth reporting invalid when cookie is stale#39
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
…ed parsing ClassicLevel on a temporary copy avoids prefix-compression artifacts that corrupt tokens when reading raw .ldb files. Add extractCookie() for standalone cookie refresh. Structured teams-object parsing extracts all workspaces from localConfig_v2. Strip leading control bytes from LevelDB values before JSON parsing.
fd21d97 to
b8fea99
Compare
There was a problem hiding this comment.
1 issue found across 4 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/platforms/slack/ensure-auth.ts">
<violation number="1" location="src/platforms/slack/ensure-auth.ts:47">
P2: `refreshCookie` duplicates existing cookie-refresh logic from `auth.ts`; this should be centralized to avoid behavior drift between auth paths.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
src/platforms/slack/ensure-auth.ts
Outdated
| } | ||
| } | ||
|
|
||
| async function refreshCookie(token: string, credManager: CredentialManager): Promise<boolean> { |
There was a problem hiding this comment.
P2: refreshCookie duplicates existing cookie-refresh logic from auth.ts; this should be centralized to avoid behavior drift between auth paths.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/platforms/slack/ensure-auth.ts, line 47:
<comment>`refreshCookie` duplicates existing cookie-refresh logic from `auth.ts`; this should be centralized to avoid behavior drift between auth paths.</comment>
<file context>
@@ -32,6 +41,24 @@ export async function ensureSlackAuth(): Promise<void> {
+ }
+}
+
+async function refreshCookie(token: string, credManager: CredentialManager): Promise<boolean> {
+ try {
+ const extractor = new TokenExtractor()
</file context>
Auth status and ensureSlackAuth now validate stored credentials via auth.test API call and attempt cookie refresh before reporting invalid or falling back to full extraction. This fixes the case where the Slack desktop app works but agent-messenger reports valid:false due to an expired cookie in stored credentials.
b8fea99 to
619aa48
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
slack auth statusreportsvalid: falseeven though the Slack desktop app works fine. The root cause is stale cookies in stored credentials — the token is valid but the cookie has expired, causingauth.testto fail withinvalid_auth.ensureSlackAuthnow validate stored credentials and attempt a cookie refresh before reporting invalid or falling back to full extraction..ldbfiles.Changes
src/platforms/slack/token-extractor.tsextractCookie()method for standalone cookie refresh without full token extraction.extractFromLevelDB()prefers ClassicLevel on a temp copy to avoid prefix-compression corruption, with fallback to raw.ldbscan and direct ClassicLevel.parseTokenValue(),parseTeamsObject(),parseSingleToken()for structured token parsing. HandleslocalConfig_v2teams object format.0x01) from LevelDB values before JSON parsing.src/platforms/slack/commands/auth.tsstatusActionretries with a fresh cookie viatryRefreshCookie()before marking auth as invalid.tryRefreshCookie()extracts a fresh cookie, validates it against the API, and updates all stored workspaces.src/platforms/slack/ensure-auth.tsauth.testAPI call on startup.refreshCookie()before falling back to full extraction.src/platforms/slack/ensure-auth.test.tsVerified
bun typecheck— clean.bun test— 868 pass, 0 fail.slack auth extractreturns 4 workspaces,slack auth statusreturnsvalid: true.Summary by cubic
Fixes Slack auth showing invalid when the cookie is stale. Adds a cookie refresh flow and makes token extraction from LevelDB more reliable.
Bug Fixes
Refactors
Written for commit 619aa48. Summary will update on new commits.