Skip to content

[INFRA-1118] fix(security): make work item system fields read-only - #10048

Merged
sriramveeraghanta merged 4 commits into
previewfrom
fix/infra-1118-readonly-issue-deleted-at
Oct 18, 2026
Merged

sriramveeraghanta merged 4 commits into
previewfrom
fix/infra-1118-readonly-issue-deleted-at

Conversation

@dheeru0198

@dheeru0198 dheeru0198 commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Description

deleted_at was writable through the work item update serializers. It is now read-only, so removing a work item always goes through the delete endpoints and their role checks.

  • plane/api/serializers/issue.py: IssueSerializer.Meta.read_only_fields now includes deleted_at (v1 work item PATCH and the v1 intake issue PATCH).
  • plane/app/serializers/issue.py: IssueCreateSerializer.Meta.read_only_fields now includes deleted_at (app issue create/update/partial_update, intake issue update, draft-to-issue).
  • deleted_at is still returned in responses. No client sends it in an update payload, and there is no restore flow that writes it through these serializers.
  • archived_at and sequence_id are now read-only on both serializers too. Archive/unarchive keep using their dedicated endpoints, which set archived_at on the model directly; sequence_id is always assigned by Issue.save() on create. No client in apps/web, apps/space or packages sends either field in an issue create/update payload.
  • is_draft is read-only when updating an existing work item through either serializer, and stays writable on create. The update endpoints only load work items that are not drafts, so no update path can legitimately change it. The web issue form may echo the current is_draft value on update; that value is now ignored.
  • On work item PATCH (app and v1), the v1 external-id upsert, and intake issue updates (app and v1), the serializer's read-only fields are left out of the data passed to issue_activity and model_activity (shared plane.utils.serializers.writable_data helper), so an ignored field does not record activity or send notifications or webhooks.
  • created_by on the v1 serializer is left to [INFRA-772] fix(security): stop trusting body-supplied created_by/created_at on external API #9704, which already makes it read-only on the PATCH path. Both PRs edit the same v1 read_only_fields list, so whichever lands second needs a small rebase that keeps all entries.

Behaviour change: deleted_at, archived_at or sequence_id in a create or update payload, or is_draft in an update payload, is ignored instead of being saved.

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

  • v1 PATCH /api/v1/workspaces/<slug>/projects/<id>/work-items/<id>/ as a project member with {"name": ..., "deleted_at": ...} → 200, name updated, deleted_at stays null.
  • App PATCH /api/workspaces/<slug>/projects/<id>/issues/<id>/ as a project member with the same payload → 204, name updated, deleted_at stays null.
  • The same two PATCHes with archived_at or sequence_id → name updated, the field is unchanged, and the field is absent from the activity and webhook payloads.
  • The same two PATCHes with is_draft: true → the work item stays visible (is_draft unchanged); is_draft is still writable on create.
  • Intake issue PATCH (app and v1) with {"issue": {"name": ..., "archived_at": ...}} → name updated, archived_at stays null, no archive activity recorded.
  • test_issue_read_only_fields.py (v1) and test_issue_read_only_fields_app.py (app) are parametrized over all four fields; each case fails against the pre-PR serializers and passes with the change. The intake tests fail without the activity filtering.
  • plane/tests: 777 passed.

References

  • INFRA-1118
  • INFRA-1202

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Prevented work item updates from changing the deletion timestamp. Other fields, such as the item name, can still be updated normally.

…rializers

Add deleted_at to read_only_fields on the v1 IssueSerializer and the app
IssueCreateSerializer, so PATCH cannot set it; deletion stays on DELETE.
Also covers INFRA-1202.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 16, 2026 18:56

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 reached their quota limit.

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.

@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e929d0c8-a715-4758-81a1-9411b18e6a1f
📥 Commits

Reviewing files that changed from the base of the PR and between 4e0e403 and 13111a6.

📒 Files selected for processing: 4
  • apps/api/plane/api/serializers/issue.py
  • apps/api/plane/app/serializers/issue.py
  • apps/api/plane/tests/contract/api/test_issue_deleted_at_read_only.py
  • apps/api/plane/tests/contract/app/test_issue_deleted_at_read_only_app.py

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

📝 Walkthrough

Both issue serializers now mark deleted_at as read-only. Contract tests verify that API and app partial updates can change the issue name without setting deleted_at.

Changes: Issue deletion timestamp protection

Layer / File(s) Summary
Read-only fields and partial-update contracts
apps/api/plane/api/serializers/issue.py, apps/api/plane/app/serializers/issue.py, apps/api/plane/tests/contract/api/test_issue_deleted_at_read_only.py, apps/api/plane/tests/contract/app/test_issue_deleted_at_read_only_app.py
Both serializers add deleted_at to their read-only fields. Contract tests verify that PATCH requests update the name while leaving deleted_at unset.

Priority: ➖ Normal

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

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 13111

Clients can no longer set an issue's deletion timestamp through create or update payloads. Deletion still goes through the delete endpoints. No merge-blocking risk remains.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
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 clearly identifies the security fix and the main change: making work item system fields read-only.
Description check Passed The description includes all template sections, explains the behavior change, identifies affected serializers, documents test scenarios, and provides references.
  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 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

Comment @coderabbitai help to get the list of available commands.

Make archived_at and sequence_id read-only on the v1 and app work item
serializers; archive/unarchive keep their dedicated endpoints.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@dheeru0198 dheeru0198 changed the title [INFRA-1118] fix(security): make deleted_at read-only on work items [INFRA-1118] fix(security): make work item system fields read-only Oct 16, 2026

@lovelace3 lovelace3 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.

No blocking findings. One minor finding inline.

Verified

  • Both new test modules pass (6/6). Falsified against the merge-base serializers: all 6 cases fail, so the tests guard the change.
  • Write paths: app IssueCreateSerializer (issue create/update, intake update, draft-to-issue) and v1 IssueSerializer (work item PATCH, v1 intake PATCH) are the only serializers that write Issue. The other Issue serializers are read-only or never bound to request data. Archive/unarchive and delete still set the fields on the model directly.
  • Regression sweep (plane/tests/contract + unit/serializers + unit/views): everything passes except the same 12 magic-link tests in test_authentication.py, which fail identically on all four of your heads #10048–#10051. This PR doesn't touch auth, so they're environmental, not regressions.

Test note (minor): both new tests need WEB_URL/APP_BASE_URL set. Without it the PATCH 500s in base_host() (ImproperlyConfigured) before the assertion. Other contract tests (test_issue_subresource_scope_app.py, unit/views/test_issue_link.py) patch base_host and the .delay tasks so they run in a bare env. Doing the same here would make these tests independent of a local .env.

"updated_at",
"completed_at",
"deleted_at",
"archived_at",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Minor: an ignored archived_at still writes an "archived" activity. partial_update (and v1 patch) pass the raw request.data to issue_activity. ISSUE_ACTIVITY_MAPPER maps archived_at to track_archive_at, which compares the request value with current_instance. So a PATCH carrying archived_at now leaves the field unchanged, yet history records "Actor has archived the issue" (new_value=manual_archive) and the activity task runs with notification=True. Sending archived_at: null on an archived item gives a false "restored" entry the same way.

Probe on this head (member PATCH {"archived_at": "2020-01-01"}, then the activity task run on the captured kwargs): response 204, issue.archived_at stays None, and the activity rows are [('archived_at', 'manual_archive', 'Actor has archived the issue')].

Before this PR the entry matched a real change. Now it can be forged. Suggested fix: build requested_data from the keys the serializer accepted (e.g. drop serializer.Meta.read_only_fields from request.data), or have track_archive_at compare against the saved instance.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Addressed in a442001 (ignored fields no longer recorded in activity).

@dheeru0198

Copy link
Copy Markdown
Member Author

Re the test note: the suite's documented runner (docker-compose-test.yml) loads apps/api/.env, which sets WEB_URL/APP_BASE_URL and provides the broker, and most contract tests depend on that. Keeping these tests consistent with that setup rather than stubbing here.

dheeru0198 and others added 2 commits October 17, 2026 11:15
- Leave the serializer's read-only fields out of the data passed to
  issue_activity and model_activity on work item PATCH (app and v1), so an
  ignored field such as archived_at no longer records activity or sends
  notifications and webhooks.
- Tests assert the ignored field is absent from both payloads.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- is_draft is read-only when updating a work item through the app
  IssueCreateSerializer and the v1 IssueSerializer; create is unchanged
- Intake updates (app and v1) and the v1 external-id upsert send only
  the writable fields to issue/model activity, via a shared
  writable_data helper also used by the existing work item updates
- Tests: is_draft on work item PATCH (app and v1), intake updates with
  archived_at record no archive activity (app and v1)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@lovelace3 lovelace3 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.

Follow-up on 852909e.

Earlier findings:

  • Resolved: an ignored archived_at produced a forged archive/restore activity. Activity and webhook payloads now go through writable_data(serializer, data). That covers all five serializer-backed update paths that feed issue.activity.updated with request data: app issue PATCH, app intake PATCH, v1 work-item PATCH, the v1 external-id PUT upsert, and v1 intake PATCH. The other issue.activity.updated callers (archive, sub-issue, date bulk update, estimate) build their own payloads. Every key ISSUE_ACTIVITY_MAPPER tracks, apart from archived_at, is still a writable field on both serializers, so real changes are still recorded.
  • Not resolved (minor, test hygiene): the new and changed tests still need WEB_URL/APP_BASE_URL. The activity tasks are mocked now, but base_host() is evaluated as an argument before the mock is reached. With those vars unset, 11 of the 14 cases fail with ImproperlyConfigured.

New in 852909e: is_draft is read-only on update in both serializers and stays writable on create. Issue rows with is_draft=True are hidden by IssueManager, and 0077 moved the legacy drafts to DraftIssue. Workspace drafts in the web client use the draft endpoints, not this serializer, so I found no legitimate update flow that this breaks. No new findings.

Untested: the v1 PUT (external-id upsert) activity change. The code is the same two lines as on PATCH.

Tests: the 4 modules (api/test_intake_issue_update.py, api/test_issue_read_only_fields.py, app/test_intake_issue_read_only_fields_app.py, app/test_issue_read_only_fields_app.py) give 14 passed. Falsification: with the six changed source files reset to 53b5663 and utils/serializers.py removed, 10/14 fail. That includes every is_draft case and both intake no-archive-activity tests. The 4 that pass are the two create-writability checks and two intake tests that already passed before this change.

@sriramveeraghanta
sriramveeraghanta merged commit 9dc9a01 into preview Oct 18, 2026
16 checks passed
@sriramveeraghanta
sriramveeraghanta deleted the fix/infra-1118-readonly-issue-deleted-at branch October 18, 2026 09:51
sriramveeraghanta pushed a commit that referenced this pull request Oct 22, 2026
…10048)

* [INFRA-1118] fix(security): make deleted_at read-only on work item serializers

Add deleted_at to read_only_fields on the v1 IssueSerializer and the app
IssueCreateSerializer, so PATCH cannot set it; deletion stays on DELETE.
Also covers INFRA-1202.

* [INFRA-1118] fix(security): address review

Make archived_at and sequence_id read-only on the v1 and app work item
serializers; archive/unarchive keep their dedicated endpoints.

* [INFRA-1118] fix(security): address review feedback

- Leave the serializer's read-only fields out of the data passed to
  issue_activity and model_activity on work item PATCH (app and v1), so an
  ignored field such as archived_at no longer records activity or sends
  notifications and webhooks.
- Tests assert the ignored field is absent from both payloads.

* [INFRA-1118] fix(security): address review feedback

- is_draft is read-only when updating a work item through the app
  IssueCreateSerializer and the v1 IssueSerializer; create is unchanged
- Intake updates (app and v1) and the v1 external-id upsert send only
  the writable fields to issue/model activity, via a shared
  writable_data helper also used by the existing work item updates
- Tests: is_draft on work item PATCH (app and v1), intake updates with
  archived_at record no archive activity (app and v1)
sriramveeraghanta pushed a commit that referenced this pull request Nov 9, 2026
…10048)

* [INFRA-1118] fix(security): make deleted_at read-only on work item serializers

Add deleted_at to read_only_fields on the v1 IssueSerializer and the app
IssueCreateSerializer, so PATCH cannot set it; deletion stays on DELETE.
Also covers INFRA-1202.

* [INFRA-1118] fix(security): address review

Make archived_at and sequence_id read-only on the v1 and app work item
serializers; archive/unarchive keep their dedicated endpoints.

* [INFRA-1118] fix(security): address review feedback

- Leave the serializer's read-only fields out of the data passed to
  issue_activity and model_activity on work item PATCH (app and v1), so an
  ignored field such as archived_at no longer records activity or sends
  notifications and webhooks.
- Tests assert the ignored field is absent from both payloads.

* [INFRA-1118] fix(security): address review feedback

- is_draft is read-only when updating a work item through the app
  IssueCreateSerializer and the v1 IssueSerializer; create is unchanged
- Intake updates (app and v1) and the v1 external-id upsert send only
  the writable fields to issue/model activity, via a shared
  writable_data helper also used by the existing work item updates
- Tests: is_draft on work item PATCH (app and v1), intake updates with
  archived_at record no archive activity (app and v1)

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

4 participants