Repository navigation
X 号缺发图权限记成权限不够只叫人重连,别的 403 只败这一条,GIF 等处理完,改稿被拒会报错 - #128
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Be3SZps2JjqvyrJ1vbLmni
…的 403 不说内容重复(先红) (#38) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Be3SZps2JjqvyrJ1vbLmni
…叫人重连,发帖那步的照旧算平台拒了;中枢改稿只认这个 Bot 自己起的草稿;平台拒了这一条的通知按平台写缘故;等动图的定时器 unref (#38) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Be3SZps2JjqvyrJ1vbLmni
joesmart
force-pushed
the
joesmart/fix-x-token-scope
branch
from
October 25, 2026 13:49
f2ea3cf to
81e2255
Compare
Closed
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.
为什么
#118 让接口授权的 X 草稿能带图,传图要
media.write。之前连上的 X 号授权里没有它,X 回 403,代码把所有 403 都记成登录过期:账号整个变「已过期」,连发字都停了。产品定了:权限不够单独一个状态,只叫人重连。改了什么
shared的Account加missingScope: AccountScope | null(字面量联合,现在只有media.write),失败原因加missing_scope、forbidden、media_failed。login仍只管令牌死没死,expired只留给 401 且换不到新令牌。迁移 0052 只加accounts.missing_scope一列,不回填。control-plane/src/publish/forbidden.ts的classifyForbidden看这一条要不要额外范围、授权时存下的 scope、X 的回包。缺范围 → 账号记missing_scope、登录照旧有效,这一条记权限不够;别的 403(内容重复、GitHub 无权限)→ 账号不动,只这一条失败,原因写明是平台拒了这一条。media.write的,带图的稿子认领时就记权限不够,一条请求都不打;不带图的照发。授权回调和刷新令牌都按平台回的 scope 重算missing_scope,重连给全了就清掉。账号状态变化照旧按凭据代际比,被拒之后已重连的不改。/2/media/upload回包带processing_info的,按check_after_secs查STATUS,到succeeded才挂到帖子上;failed或等满 5 分钟记media_failed,不发帖。等待由注入的sleep做,测试不真等。edit_draft改走中枢POST /hub/v1/drafts/:id/edit,当场拿到结果。正在发或已发出、改了类型、配图不合规则、找不到的,控制面回中文原因,运行器抛「草稿没改:…」,模型拿到isError工具结果。旧运行器的draft_edit上行照收。怎么验的
先红:新测试在 main 上都红(控制面撤掉实现 7 条失败,
forbidden.test.ts缺模块;运行器撤掉 src 2 条失败;Web 撤掉 UI 2 条失败,找不到scope-reconnect-text)。另用 Playwright 对 mock 点过账号页和草稿卡,390 宽不横向滚动。全程不打真 X 接口。
复核后补的几处
scope时存成空串,原来saveGrant拿空串重算,把授权时记下的missing_scope清成 null,凭据的 scope 也被覆盖成空串,之后真缺media.write的 403 会被说成「内容重复」。现在scope为空串时,凭据上已存的 scope 和账号的missing_scope都不动,SavedGrant带回落库后算数的 scope,刷新拿到的令牌用它做发前预检。PlatformForbidden带step(upload传图,post发帖),X 的传图循环里碰到的 403 改标成upload。classifyForbidden仍是纯函数,多一条:传图那一步回不点名的 403,而 scope 不知道(account-add挂的号恒为空串),按缺media.write处理,叫人重连。内容重复只会出在发帖那一步,发帖那一步不点名的 403 照旧记forbidden。editDraft的条件补上drafts.bot_id,同群别的 Bot 起的草稿回 404,和 README 说的一致。旧上行draft_edit走同一个函数,同样只改自己的。forbidden的通知 GitHub 写「GitHub 拒绝了这一条,账号授权还有效,多半是仓库权限、组织的 SSO 或限流」,X 保留原文案。unref,关进程时不为等动图多挂一分钟。新用例:
oauth.test.ts「X 刷新令牌的回包不带 scope:已知缺的发图权限还记着,存下的 scope 不变」publish.test.ts「不知道给过哪些权限的 X 号,传图那一步回不点名的 403:账号记缺发图权限、登录照旧有效,这条记权限不够、叫人重连」publish.test.ts「不知道给过哪些权限的 X 号,图传上去了、发帖那一步回不点名的 403:只这一条记平台拒了,账号不动」publish.test.ts「多 Bot 群里另一个 Bot 经中枢改别人起的草稿:回 404,草稿不动」publish.test.ts「X 别的 403 和 GitHub 的 403 都不动账号…」补断言 GitHub 的通知文案forbidden.test.ts表驱动每行带上step,新增 5 行:scope 不知道传图回通用 403、回空 403,scope 缺发图权限传图回通用 403,都算缺;scope 不知道发帖回通用 403、scope 有发图权限传图回通用 403,都算平台拒了先红(在 e85d2ad 的实现上跑新用例):6 条失败,其中「发帖那一步回不点名的 403」那条本来就绿,是守着不退化的。
复核后的门禁(head f2ea3cf):
这一轮没动 web 和 shared,web 测试没重跑。
Closes #38
🤖 Generated with Claude Code
https://claude.ai/code/session_01Be3SZps2JjqvyrJ1vbLmni