Skip to content

[Entity-Service] fix incident attachment upload in dual-write mode - #3022

Merged
rksk merged 1 commit into
wso2-open-operations:mainfrom
rksk:fix/incident-attachment-dual-write
Oct 26, 2026
Merged

rksk merged 1 commit into
wso2-open-operations:mainfrom
rksk:fix/incident-attachment-dual-write

Conversation

@rksk

@rksk rksk commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Purpose

In dual-write mode, uploading an attachment to an incident returned HTTP 400. Incident, change request and conversation uploads were sent to the mirrored data source and then a case attachment row keyed by the work item id was inserted, which violates the case foreign key. The file existed in the mirrored source but the caller saw an error. Listing attachments for these types read a synced table whose sync is stopped, so new uploads never appeared.

Goals

Creating and listing attachments for incident, change request and conversation works in dual-write mode.

Approach

Added one helper, isMirrorOnlyAttachmentRef, covering deployment plus the three non-case work item types. In dual-write mode, create uploads to the mirrored source only (no actor resolution, no Postgres insert) and returns its response, and search reads from the mirrored source. Plain postgres mode and case behaviour are unchanged. This is a temporary stopgap until Postgres-backed attachment storage for non-case work items exists, at which point the helper's non-deployment arms should be removed. Diff: 4 files, +118/-11, entity-service only. Update and delete behaviour are not changed.

User stories

N/A: bug fix.

Release note

Fixed attachment upload and listing for incidents, change requests and conversations in dual-write mode.

Documentation

N/A: no documented behaviour change.

Training

N/A: no training impact.

Certification

N/A: no impact on certification exams.

Marketing

N/A: bug fix.

Automation tests

  • Unit tests

    Added/updated in internal/service: dual-write create for incident, change_request and conversation calls the mirror only (repo insert and actor resolution never reached) and returns mirror errors unchanged; case create still resolves the actor, uploads and inserts (existing test); plain postgres incident create still returns the validation error; search for the three types goes to the mirror in dual-write and to the repository in plain postgres. go vet ./... and go test ./... -count=1 pass.

  • Integration tests

    N/A: covered by service-level unit tests with stubbed repository and mirror.

Security checks

Samples

N/A: no samples.

Related PRs

None.

Migrations (if applicable)

N/A: no schema changes.

Test environment

Go unit tests on macOS.

Learning

N/A: follows the existing deployment stopgap pattern.

In dual-write mode, incident, change_request and conversation attachment
uploads went to the mirrored data source and then tried to insert a
case_attachment row keyed by the work item id, which violates the case
foreign key and surfaced as a 400. Searches for these types read the
work_item_attachment table, which is no longer being synced, so new
uploads never appeared.

Treat these types like deployment in dual-write mode: create uploads to
the mirror only and returns its response, search reads from the mirror.
Plain postgres mode and case behaviour are unchanged. Temporary stopgap
until a Postgres-backed storage for non-case work items exists.
@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 8 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 0454a67 and 45e6a9f.

Files selected for processing: 4
  • entity-service/internal/service/case_attachment_dual_write_service.go
  • entity-service/internal/service/case_attachment_dual_write_service_test.go
  • entity-service/internal/service/case_attachment_service_test.go
  • entity-service/internal/service/case_service.go
  • 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.

@rksk
rksk marked this pull request as ready for review October 26, 2026 03:34
@rksk
rksk merged commit 87f1440 into wso2-open-operations:main Oct 26, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants