Skip to content

[WEB-10170] fix: omit the token from API token PATCH - #10302

Merged
sriramveeraghanta merged 1 commit into
previewfrom
fix/web-10170-api-token-patch-response
Nov 16, 2026
Merged

sriramveeraghanta merged 1 commit into
previewfrom
fix/web-10170-api-token-patch-response

Conversation

@pablohashescobar

@pablohashescobar pablohashescobar commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Description

PATCH /api/users/api-tokens/<id>/ responded with APITokenSerializer, which includes the secret token. The token is meant to be shown once, at creation; GET already uses APITokenReadSerializer, which leaves it out.

patch now returns APITokenReadSerializer(api_token).data.

Behavior change: the PATCH response no longer contains token, and is_active is the expiry-derived value the GET endpoints return. No frontend calls this PATCH.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring
  • Performance improvements
  • Documentation update

Screenshots and Media (if applicable)

Test Scenarios

  • New test_patch_response_excludes_token in plane/tests/contract/app/test_api_token.py; the existing create test still asserts POST returns the token. Module: 21 passed.

References

  • WEB-10170

Created with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Successful API token updates now return the updated label without including the token value in the response. The response continues to indicate success, and invalid updates continue to return validation errors. This keeps the update result focused on the changed information while preserving the existing behavior for unsuccessful requests.

The token value is meant to be visible only in the create response. Respond to PATCH with the read serializer, which excludes it.
Copilot AI balanced review requested due to automatic review settings November 15, 2026 22:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@makeplane

makeplane Bot commented Nov 15, 2026

Copy link
Copy Markdown

Linked to Plane Work Item(s)

This comment was auto-generated by Plane

@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Successful API token PATCH responses now use APITokenReadSerializer. A contract test checks that the response includes the updated label and omits the token value.

Changes: API token PATCH response

Layer / File(s) Summary
Serialize and test PATCH responses
apps/api/plane/app/views/api.py, apps/api/plane/tests/contract/app/test_api_token.py
Successful PATCH responses use APITokenReadSerializer. The test checks the updated label and confirms the response omits the token value.

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Bug fix

Merge Risk: Minimal · up to 66314

PATCH on an API token no longer returns the token value in its response, which closes an unnecessary exposure of the secret. Callers that relied on the old response shape would see a change, but none is known. The risk of merging is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Description check Passed The description covers the required template sections. It explains the problem and the fix in the Description section. It marks the Bug fix type. It lists test scenarios and links the ticket WEB-10170…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title '[WEB-10170] fix: omit the token from API token PATCH' matches the main change. The PATCH handler in ApiTokenEndpoint now serializes successful responses with APITokenReadSerializer instead …
Full details: Description check

Explanation

The description covers the required template sections. It explains the problem and the fix in the Description section. It marks the Bug fix type. It lists test scenarios and links the ticket WEB-10170 under References. The Screenshots section is left as an unfilled placeholder, which is acceptable because the template marks it as applicable only when relevant. It also documents a behavior change: the PATCH response no longer includes token and is_active now uses the expiry-derived value. The description is mostly complete.

Full details: Title check

Explanation

The title '[WEB-10170] fix: omit the token from API token PATCH' matches the main change. The PATCH handler in ApiTokenEndpoint now serializes successful responses with APITokenReadSerializer instead of APITokenSerializer, so the token value is no longer returned. A regression test, test_patch_response_excludes_token, was added to confirm the response omits the token and returns the updated label.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8b57b025-1eda-4982-a6cd-19205b78ce43
Commits

Reviewing files that changed from the base of the PR and between 290383d and 66314aa.

Files selected for processing: 2

  • apps/api/plane/app/views/api.py
  • apps/api/plane/tests/contract/app/test_api_token.py

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

@pablohashescobar pablohashescobar changed the title [WEB-10170] fix(security): omit the token from API token PATCH [WEB-10170] fix: omit the token from API token PATCH Nov 16, 2026

@sriramveeraghanta sriramveeraghanta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

@sriramveeraghanta
sriramveeraghanta merged commit 97fe540 into preview Nov 16, 2026
19 of 21 checks passed
@sriramveeraghanta
sriramveeraghanta deleted the fix/web-10170-api-token-patch-response branch November 16, 2026 20:23
sriramveeraghanta pushed a commit that referenced this pull request Nov 16, 2026
The token value is meant to be visible only in the create response. Respond to PATCH with the read serializer, which excludes it.
Pawel-Kranzberg pushed a commit to klazwi/pi-plane that referenced this pull request Nov 18, 2026
The token value is meant to be visible only in the create response. Respond to PATCH with the read serializer, which excludes it.

(cherry picked from commit 2cffcce)
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.

3 participants