Skip to content

【substack-mcp】Notes投稿エラーを安全に診断・修正する - #9

Draft
nanameru wants to merge 5 commits into
issue-6-cloudflare-deployfrom
issue-8-note-error
Draft

nanameru wants to merge 5 commits into
issue-6-cloudflare-deployfrom
issue-8-note-error

Conversation

@nanameru

@nanameru nanameru commented Sep 12, 2026

Copy link
Copy Markdown
Owner

Closes #8

変更概要

  • post_note の上流HTTP失敗を SubstackHTTPError に変換し、HTTP statusと許可リスト済み識別子だけを公開
  • 上流レスポンス本文、投稿本文、Cookie、スタックトレースを本番レスポンス・ログへ出さない
  • Notes用ProseMirror documentから title: null を削除
  • Notes endpointを末尾スラッシュ付きの現行形式へ統一
  • 実送信しない回帰テスト5件とtest-board TC-002を追加

検証結果

  • .venv/bin/python -m unittest discover -s tests -p 'test_*.py': 5件成功
  • .venv/bin/python -m compileall -q src tests: 成功
  • npm run type-check: 成功
  • npm ci: 脆弱性0件
  • npx wrangler deploy --dry-run: Worker bundleとContainer image build成功
  • test-board impact / test-board issue --issue 8: TC-001、TC-002の影響を確認
  • Cloudflare本番Version 7b8978fa-fe19-482c-9da0-0c9ee514740a: デプロイ成功
  • GET /: HTTP 200
  • 匿名 POST /mcp: HTTP 401
  • GPT Workの list_drafts(limit=1): 成功(書き込み系ツール未実行)

リスク

  • Substack Notesは非公開APIのため、今後の仕様変更はあり得る
  • ライブNotes投稿はこのPRの検証では行わない
  • エラー診断は情報漏えい防止のため、自由形式の上流メッセージを意図的に破棄する

PR構成

PR #7 の本番Cloudflare実装を前提とするstacked Draft PR。自動マージしない。

@amazon-q-developer amazon-q-developer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This PR successfully implements safe error handling for Substack Notes posting. The security improvements effectively prevent information leakage by sanitizing HTTP error responses and limiting exposed diagnostic data to safe, allowlisted identifiers. The implementation correctly fixes the Notes endpoint URL and removes the problematic title: null attribute. The comprehensive test coverage validates the security measures without requiring live API calls. All changes align with the stated objectives and maintain proper separation of concerns.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

@nanameru

Copy link
Copy Markdown
Owner Author

追加診断版デプロイ完了

  • コミット: 88bec01
  • Cloudflare Worker Version: 228f82e1-4b89-493e-abd4-89e2e80dddf7
  • Container image digestを更新
  • post_note の失敗phaseを request / response_json / response_shape に分類
  • 公開する診断値はoperation、phase、例外型、HTTP statusのみ。例外メッセージ、投稿本文、上流body、Cookie、session tokenは破棄
  • 回帰テスト7件、Python構文、TypeScript型検査、Container dry-run成功
  • デプロイ後のGPT Work list_drafts(limit=1) 成功
  • Notes投稿の2回目は未実行、定期タスクはPausedを維持

次の1回で、失敗した場合も phase=request などから原因箇所を確定できる。公開操作になるため、利用者の再承認待ち。

@nanameru

Copy link
Copy Markdown
Owner Author

追加更新: ChatGPTがpost_note本文をtextとして渡さないケースに対応し、text/content互換入力をtextへ正規化しました(4fe7d4c)。7回帰テスト、構文、型検査、Wrangler dry-runに成功し、Worker Version c0454f93-fa53-406f-b687-4125c7f5780bへデプロイ済みです。デプロイ後のlist_drafts(limit=1)も成功。書き込み再テストは未実施で、定期タスクは停止中です。

@nanameru

Copy link
Copy Markdown
Owner Author

本番確認結果: post_note を承認済みの1回だけ実行し、公開feedでNote ID 335417972の本文反映を確認しました。重複なし。記録更新は ff106b1。定期タスク再開は別途ユーザー確認待ちです。

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