Skip to content

Content references: Avoid requesting references for content that is not yet persisted server side#21035

Merged
nielslyngsoe merged 6 commits intorelease/17.0from
v17/bugfix/avoid-unnecessary-request-for-references-for-non-created-content
Dec 3, 2025
Merged

Content references: Avoid requesting references for content that is not yet persisted server side#21035
nielslyngsoe merged 6 commits intorelease/17.0from
v17/bugfix/avoid-unnecessary-request-for-references-for-non-created-content

Conversation

@AndyButland
Copy link
Contributor

Prerequisites

  • I have added steps to test this contribution in the description below

Relates to #21034 which fixes a failing test caused by #20999, which in turn was resolving an API regression in 17.

Description

With the update from the linked PR above, a request for a content item that doesn't exist will now return a 404. This seems semantically request from an API perspective, but currently the backoffice client is requesting this endpoint for new content, that is not yet persisted. This leads to an error response for a network request in the console, and impacted an E2E test.

This PR avoids making the request when the entity is new, which avoids getting the 404 response, and also removes one unnecessary network request.

Testing

Create a new document and immediately browse to the "Info" tab. You should see no API request to /umbraco/management/api/v1/document/{id}}/referenced-by.

From an existing content item, the "Info" tab should continue to display the references.

Copilot AI review requested due to automatic review settings December 2, 2025 18:48
@AndyButland AndyButland force-pushed the v17/bugfix/avoid-unnecessary-request-for-references-for-non-created-content branch from ed9a586 to d4e260e Compare December 2, 2025 18:49
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes an issue where the backoffice client was requesting content references for new, unpersisted documents, resulting in unnecessary 404 API errors. The fix adds a check for the isNew state before making the API request to fetch referenced-by data.

Key changes:

  • Add import for UmbSubmittableWorkspaceContext type to check entity persistence state
  • Implement early return logic when entity is new (not yet persisted server-side)
  • Set empty results (_total = 0, _items = []) for new entities instead of making API request

@AndyButland AndyButland changed the base branch from main to release/17.0 December 2, 2025 19:54
@nielslyngsoe nielslyngsoe enabled auto-merge (squash) December 3, 2025 11:50
@nielslyngsoe nielslyngsoe merged commit 86411e4 into release/17.0 Dec 3, 2025
24 checks passed
@nielslyngsoe nielslyngsoe deleted the v17/bugfix/avoid-unnecessary-request-for-references-for-non-created-content branch December 3, 2025 12:25
leekelleher pushed a commit that referenced this pull request Dec 3, 2025
 #21009) (#21027)

* fix: uses 'href' as property instead of attribute

* build: runs on PR to release branches

* Content references: Avoid requesting references for content that is not yet persisted server side (#21035)

* Avoid requesting references for content that is not yet persisted server side.

* Apply suggestions from code review

Co-authored-by: Copilot <[email protected]>

* refactor to use condition

* revert

* danish translations

* da translation

---------

Co-authored-by: Copilot <[email protected]>
Co-authored-by: Niels Lyngsø <[email protected]>

* fix: CTRL+Click now opens links in new tab on Linux

The router's anchor click handler incorrectly assumed non-Windows
platforms use Meta (⌘) key for "open in new tab". This broke
CTRL+Click on Linux, which uses CTRL like Windows.

Changed detection from "is Windows" to "is Mac" so Linux correctly
uses CTRL+Click while Mac continues to use Meta+Click.

Also replaced deprecated navigator.platform with navigator.userAgent.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

---------

Co-authored-by: Andy Butland <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Niels Lyngsø <[email protected]>
Co-authored-by: Claude <[email protected]>
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.

4 participants