Skip to content

fix: improve 401 error messages and document required scopes for scoped API tokens#77

Merged
pchuri merged 3 commits intomainfrom
claude/fervent-carson
Mar 13, 2026
Merged

fix: improve 401 error messages and document required scopes for scoped API tokens#77
pchuri merged 3 commits intomainfrom
claude/fervent-carson

Conversation

@pchuri
Copy link
Owner

@pchuri pchuri commented Mar 13, 2026

Summary

  • Add axios response interceptor to provide context-specific 401 error messages (scoped token / basic auth / bearer)
  • Document required classic scopes for scoped API tokens in README (with table)
  • Add scope information to SKILL.md for AI agent reference
  • Add 3 unit tests for 401 error handling

Closes #76

Test plan

  • All 143 tests pass
  • Verify 401 error message with scoped token config (api.atlassian.com)
  • Verify 401 error message with regular basic auth config
  • Verify 401 error message with bearer token config

…ed API tokens

When using scoped API tokens with api.atlassian.com, users receive unhelpful
401 errors with no guidance on what went wrong. This adds an axios response
interceptor that detects 401 errors and provides context-specific hints
(scoped token vs basic auth vs bearer), and documents the required classic
scopes in README and SKILL.md.

Closes #76
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the developer/user experience around Atlassian authentication failures by adding more actionable 401 (Unauthorized) error messages and documenting the required Confluence classic scopes for scoped API tokens, with accompanying unit tests and skill/docs updates.

Changes:

  • Add an Axios response interceptor to rewrite 401 errors with context-specific guidance (scoped token vs basic vs bearer/PAT).
  • Document required classic scopes for scoped API tokens in README.md and .claude/skills/.../SKILL.md.
  • Update markdown-to-storage conversion behavior for code blocks and Cloud link rendering, and extend unit tests accordingly.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
lib/confluence-client.js Adds 401 interceptor + updates markdown-to-storage conversions (code block decoding and Cloud vs Server link output).
tests/confluence-client.test.js Adds 401 error handling tests and updates/extends markdown conversion assertions.
README.md Documents required classic scopes for scoped Confluence API tokens.
.claude/skills/confluence/SKILL.md Adds scoped-token scope guidance for agent reference.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

.replace(/&/g, '&')
.replace(/&lt;/g, '<')
.replace(/&gt;/g, '>');
return `<ac:structured-macro ac:name="code"><ac:parameter ac:name="language">${language}</ac:parameter><ac:plain-text-body><![CDATA[${decodedCode}]]></ac:plain-text-body></ac:structured-macro>`;
pchuri added 2 commits March 13, 2026 19:18
… rename misleading test

- isCloud() now returns true for scoped tokens so Cloud-specific behavior
  (e.g. smart link rendering) applies correctly
- Rename test to accurately reflect bearer/PAT auth scenario
Server/DC uses username/password for basic auth, not email/API token.
Gate the Cloud-specific hint behind isCloud() and add a separate message
for on-premise users.
@pchuri pchuri merged commit e7e3e52 into main Mar 13, 2026
6 checks passed
github-actions bot pushed a commit that referenced this pull request Mar 13, 2026
## [1.27.2](v1.27.1...v1.27.2) (2026-03-13)

### Bug Fixes

* improve 401 error messages and document required scopes for scoped API tokens ([#77](#77)) ([e7e3e52](e7e3e52)), closes [#76](#76)
@github-actions
Copy link

🎉 This PR is included in version 1.27.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEEDBACK] Scoped API token gives 401

2 participants