Skip to content

fix(slack): optional 스코프 누락을 전송 불능과 구분해 알린다 (#478) - #482

Open
parkjs101 wants to merge 1 commit into
devfrom
codex/478-scope-warning-severity
Open

fix(slack): optional 스코프 누락을 전송 불능과 구분해 알린다 (#478)#482
parkjs101 wants to merge 1 commit into
devfrom
codex/478-scope-warning-severity

Conversation

@parkjs101

Copy link
Copy Markdown
Collaborator

무엇이 문제였나

v2.17.10 이전에 설치된 Slack 앱은 channels:join, chat:write.public, team:read, mpim:read 4개가 빠져 있다. 기동 시 점검이 이걸 찾아내고 missing 4 scope(s) 를 WARN 으로 알렸는데, 그 시점에 소켓은 연결돼 있었고 봇은 정상 응답 중이었다. 제보자는 이게 "고장" 인지 "기능 일부 없음" 인지 판단할 근거가 없어서, 확인을 위해 앱을 재설치했다 (#478).

원인

판정 데이터는 처음부터 나뉘어 있었다 — missingRequiredmissingCapabilities 는 별개 배열이다. 납작해진 건 보고 단계뿐이다.

const missing = [...status.missingRequired, ...status.missingCapabilities];
const severity = status.missingRequired.length > 0 ? 'the transport needs' : 'features degrade without';

두 배열을 이어붙인 뒤 severity 를 전체에 하나만 골랐다. 그래서 두 실패가 운영자가 읽는 표면에서 구분되지 않았다.

  • chat:write 하나만 빠져도 optional 스코프까지 전부 the transport needs 로 승격됐다
  • optional 만 빠진 경우엔 일어나지도 않은 break 에서 WARN 을 빌려왔다
  • 개수가 둘에 걸쳐 있어서 어느 쪽이 몇 개인지 알 수 없었다

수정

severity 당 한 줄씩 반환하고, 각자 자기 레벨로 로깅한다.

[WARN] [slack:scopes] the transport needs 1 scope(s): chat:write — reinstall: ...
[INFO] [slack:scopes] 4 optional scope(s) not granted: channels:join, chat:write.public,
       team:read, mpim:read — messaging is unaffected; reinstall: ...

optional 줄에 messaging is unaffected 를 명시한 건 그게 제보자의 실제 질문이었기 때문이다.

매니페스트는 건드리지 않았다. 이슈의 세 번째 제안(4개를 매니페스트에 추가)은 이미 반영돼 있다 — channels:join/chat:write.public 은 v2.17.10, team:read/mpim:read 는 v2.14.0 부터 들어 있다. Slack 은 설치 시점에 grant 를 고정하므로 구버전 매니페스트로 만든 앱은 재설치 전까지 이 상태가 유지된다. 보고할 가치가 있는 상태이되, 고장은 아니다.

범위

로그 문구와 레벨만 바뀐다. 스코프 필수/선택 분류(REQUIRED_SLACK_BOT_SCOPES / SLACK_CAPABILITY_SCOPES), /api/healthslackScopes 응답, SlackScopeStatus 필드는 그대로다. 소비자는 bot.ts 한 곳뿐이었다.

테스트 (2건 신규)

고정한 계약
optional 만 빠지면 info 로만 보고한다 — WARN 이 아니다
required 가 있어도 optional 을 그 severity 로 끌고 오지 않는다 (2줄, 개수 분리)

기존 5건은 새 시그니처로 갱신했다.

증거

  • npx tsx --test tests/unit/slack-scope-drift.test.ts — 10 passed / 0 failed
  • npx tsc --noEmit exit 0
  • describeSlackScopeGap 잔여 참조 0건
  • structure/verify-counts.sh 443/443 일치

미검증으로 남긴 것: 전체 스위트(npm test)와 npm run build 는 아직 돌리지 않았다. draft 인 이유다.

A Slack app installed before v2.17.10 lacks channels:join, chat:write.public,
team:read and mpim:read. The startup check found them and announced
"missing 4 scope(s)" at WARN — while the socket was connected and the bot was
answering. The operator could not tell that from a transport that cannot run,
and reinstalled the app to find out (#478).

The status object has held missingRequired and missingCapabilities separately
all along; only the reporting flattened them. describeSlackScopeGap
concatenated both arrays and then picked ONE severity word for the result, so
the two failures were never distinguishable at the surface an operator reads:
a single missing chat:write promoted every optional scope to "the transport
needs", and an optional-only gap borrowed WARN from a break that was not
happening. The count spanned both, which is why it could not be acted on.

So it returns one line per severity now, and each logs at its own level. The
optional line says messaging is unaffected, because that was the operator's
actual question.

The manifest itself needs no change: it has carried all four scopes since
v2.17.10 (channels:join, chat:write.public) and v2.14.0 (team:read, mpim:read).
Slack fixes a grant at install time, so an app created from an older manifest
keeps the gap until it is reinstalled — a real state to report, just not a
broken one.

Fixes #478.
@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 32f69fb2-d55c-4a91-acd9-8faf6a5fb4c0

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

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