Skip to content

Check a task's change request visibility on the copy the write route loaded - #38001

Merged
sonika-shah merged 1 commit into
mainfrom
fix/task-writes-check-visibility-on-loaded-task
Nov 18, 2026
Merged

sonika-shah merged 1 commit into
mainfrom
fix/task-writes-check-visibility-on-loaded-task

Conversation

@yan-3005

@yan-3005 yan-3005 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes open-metadata/openmetadata-collate#8655

Follow-up to #37997. TaskCommentsIT.test_getTaskWithComments_success fails in the PostgreSQL + Elasticsearch + Redis lane on main since #37997 (run 44142706227): two comments are added, and the task read back shows one.

The comment and PATCH routes read the task from the database (repository.get, not cached), then checked whether the caller may read the task's change request with ChangeRequestVisibility.requireTaskVisible(id), which loaded the task again through the entity cache. That read cached the task as it was before the write, and the comment write (TaskRepository.addComment → storeEntity) does not evict it, so with the Redis cache the next read returned the task without the new comment. The stored task was correct.

The write routes (add, edit and delete comment, PATCH) now pass the task they already loaded, and the resolve check uses that copy instead of reloading it. The versions routes still load the task by id; they only read.

Type of change:

  • Bug fix

Tests:

  • TaskCommentsIT with -Pcache-tests (PostgreSQL + Elasticsearch + Redis), locally:
    • main (65a6afb): 3 runs, test_getTaskWithComments_success failed in all 3 (expected: <2> but was: <1>).
    • This branch: 3 runs, 13 tests each, 0 failures.
  • WorkflowDefinitionResourceIT.test_taskReadsShowAPendingValueOnlyToWhoMaySeeItsChangeRequest (the 403 for viewers outside the change request rule, values for the requester and reviewer): -Pcache-tests 1 run, 0 failures; MySQL 1 run, 0 failures.

Checklist:

  • I have read the CONTRIBUTING document.
  • Covered by the existing TaskCommentsIT in the cache lane, which fails without this change.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 4/5

The repository dependency must be supplied as required before merging; no new behavior bugs were found.

Findings

  1. P2 Repository lookup breaks injection rule. ▶

Summary

Task writes now check change-request access using the task already loaded from the database, avoiding an extra cache read before saving.

  • Task writes check change-request access on the copy they already loaded.

Reviews (5) · Last reviewed commit: "Check a task's change request visibility..." · Reviewed by Greptile

…loaded

The comment and PATCH routes read the task from the database, then checked whether the caller may
read its change request by loading the task again through the entity cache. That second read
cached the task as it was before the write, and the comment write does not evict it, so with the
Redis cache a later read returned the task without the new comment (TaskCommentsIT in the cache
lane).

The write routes now pass the task they already loaded, and the resolve check uses that copy.
Reads of a task's versions still load it by id.
@yan-3005
yan-3005 requested a review from a team as a code owner November 17, 2026 19:35
@yan-3005
yan-3005 requested a review from IceS2 November 17, 2026 19:35
Copilot AI balanced review requested due to automatic review settings November 17, 2026 19:35

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. Try requesting a review at a lower effort level.

@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@yan-3005
yan-3005 enabled auto-merge (squash) November 17, 2026 19:37
@gitar-bot

gitar-bot Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved 🔴 High risk

Write routes now evaluate change-request visibility against the loaded task, changing authorization decisions; mismatched task state could expose proposed values.

Write routes for task comments and PATCH now pass the already-loaded task into the change request visibility check, instead of reloading it through the entity cache, so the Redis-cached read no longer returns a stale task missing new comments. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

|| seesAll(caller, entity)
|| mayResolveTask(authorizer, securityContext, task.getId());
|| mayResolve(
(TaskRepository) Entity.getEntityRepository(Entity.TASK),

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.

P2 Repository lookup breaks injection rule. mayRead now calls Entity.getEntityRepository directly. The Java guide requires constructor-injected repositories and says not to look up static singletons inside business methods. Supply the repository through an injected dependency while keeping the already-loaded task; this also lets tests supply a repository without changing global state.

Context Used: CLAUDE.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@sonika-shah
sonika-shah merged commit 8a7d554 into main Nov 18, 2026
58 of 65 checks passed
@sonika-shah
sonika-shah deleted the fix/task-writes-check-visibility-on-loaded-task branch November 18, 2026 00:52
yan-3005 added a commit that referenced this pull request Nov 18, 2026
Main's change-request visibility (#37997, #38001) replaces this branch's
redaction helper and pending-changes column preview; the domain task list
and the task delete response keep their redaction on top of it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

3 participants