Skip to content

Fix: Retain attachment uploadStatus on draft activation - #572

Open
akgarg06 wants to merge 1 commit into
developfrom
RBSDMS-upload-status-fix-feature
Open

Fix: Retain attachment uploadStatus on draft activation#572
akgarg06 wants to merge 1 commit into
developfrom
RBSDMS-upload-status-fix-feature

Conversation

@akgarg06

@akgarg06 akgarg06 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Describe your changes

Problem
When a draft-enabled entity with @SDM.Attachments compositions is activated (draft → active), every attachment's uploadStatus was reset to the CDS default 'uploading' instead of keeping its real value (e.g. Success).

Impact:

UI shows attachments stuck on "Uploading" after save
Downloads are blocked (SDM only serves files in Success state)
Affects all CAP apps using @SDM.Attachments on draft-enabled entities
Root cause
uploadStatus is @readonly with default 'uploading'. CAP strips @readonly fields from the payload, so on activation the active rows get the DB default. The existing preserve/restore logic only covered normal CREATE — there was no handler for DraftService.EVENT_DRAFT_SAVE, so the draft-activation path fell through.

Fix
Added @Before/@after(EVENT_DRAFT_SAVE) handlers in SDMCreateAttachmentsHandler:

@before — captures each attachment's ID + uploadStatus from the draft rows (while they still exist) into a ThreadLocal.
@after — writes those values back onto the newly activated active rows via saveUploadStatusToAttachment.
Recursively walks the composition tree, so attachments at any nesting depth (e.g. Books → Chapters → attachments) are covered — not just direct compositions. Depth-bounded and wrapped in try/catch so it never blocks the save.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

Checklist before requesting a review

  • I follow Java Development Guidelines for SAP
  • I have tested the functionality on my cloud environment.
  • I have provided sufficient automated/ unit tests for the code.
  • I have increased or maintained the test coverage.
  • I have ran integration tests on my cloud environment.
  • I have validated blackduck portal for any vulnerability after my commit.

Upload Screenshots/lists of the scenarios tested

  • I have Uploaded Screenshots or added lists of the scenarios tested in description

@akgarg06
akgarg06 deployed to pr-analysis August 27, 2026 18:02 — with GitHub Actions Active
@akgarg06
akgarg06 deployed to pr-analysis August 27, 2026 18:02 — with GitHub Actions Active
@hyperspace-pr-bot

Copy link
Copy Markdown
Contributor

👋 Hi — I'm PR Bot, your SAP code review assistant.

I'll automatically review your pull requests for code quality, security, and SAP compliance. Get an overview of what I do →

What I do

  • Summarize your pull request changes
  • Review code for quality, correctness, and reliability
  • Suggest fixes when a pipeline job fails

Key commands

Command Description
/review Trigger a code review
/summarize Generate a PR summary
/ask <question> Ask about the current changes
/help See all available commands
Configure me for your team

Create .hyperspace/pull_request_bot.json in your repository:

{
  "$schema": "https://devops-insights-pr-bot.cfapps.eu10-004.hana.ondemand.com/schema/pull_request_bot.json",
  "features": {
    "control_panel": false,
    "summarize": {
      "auto_generate_summary": true,
      "auto_insert_summary": true,
      "auto_run_on_draft_pr": true,
      "use_custom_summarize_prompt": false,
      "use_custom_summarize_output_template": false,
      "excluded_paths": [],
      "auto_exclude_authors": []
    },
    "review": {
      "auto_generate_review": true,
      "auto_run_on_draft_pr": false,
      "use_custom_review_focus": false,
      "excluded_paths": [],
      "auto_exclude_authors": []
    },
    "sonar_fix": {
      "enable": true,
      "excluded_rules": []
    },
    "pipeline_fix": {
      "enable": true
    }
  },
  "excluded_paths": []
}

Full configuration reference →

*This introduction message will be shown to you only once, you will not see it in future PRs.

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.

1 participant