Skip to content

fix audit log container scoping test#1254

Merged
ankurjuneja merged 1 commit into
release26.3-SNAPSHOTfrom
26.3_fb_fixAuditLogContainerScopingTest
Jul 6, 2026
Merged

fix audit log container scoping test#1254
ankurjuneja merged 1 commit into
release26.3-SNAPSHOTfrom
26.3_fb_fixAuditLogContainerScopingTest

Conversation

@ankurjuneja

Copy link
Copy Markdown
Contributor

Rationale

The Skyline audit log "Detailed Info" popup was broken, clicking it returned a 404 for most audit entries. This caused TargetedMSContainerScopingTest to fail.

The cause is a bug in the targetedms.AuditLog database view. It uses a recursive query that's supposed to walk the whole chain of audit entries for a document, but the recursion runs in the wrong direction. As a result, the view only ever returns the first entry in each chain instead of all of them.

The code that renders the detail popup looks up an entry by id, but the entry it needs is the last one in the chain, which the broken view never returns, so the lookup finds nothing and returns a 404.

The bug was introduced in 2022 by #502 (Issue 44507, "Allow audit log entries to belong to multiple runs"). That change flipped the query's starting point from the last entry to the first entry, but left the recursion walking in the old direction, so the two no longer matched. It has been latent ever since (the view definition is identical across 25.7, 25.11, and 26.3) and only surfaced now because the new audit-detail lookup relies on reaching entries the broken view drops.

This fix corrects the recursion direction so the view returns every entry in the chain. It also adds a schema upgrade step to rebuild the view on existing databases.

Related Pull Requests

Changes

  • targetedms-create.sql — corrected the recursive CTE to walk root → children:
    JOIN logTree prev ON prev.entryHash = nxt.parentEntryHash. Verified fix returns the full tree (7516/7516 entries; both terminal entries reachable), so retrieve() resolves them.
  • targetedms-26.008-26.009.sql (new) — drops the AuditLog view via fn_dropifexists so the corrected create.sql rebuilds it on existing installations (the drop/create pair only re-runs on a schema-version bump).
  • TargetedMSModule.getSchemaVersion() — bumped to 26.009 to trigger the view recreation on upgrade.

@ankurjuneja

ankurjuneja commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

@labkey-jeckels do you want to create the same branch in 25.11 as well or just in 25.11 and it will merge forward?

@labkey-jeckels labkey-jeckels 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.

We've muted the failure in 25.11. Patching in 26.3 is good.

@@ -0,0 +1,2 @@
-- Drop the AuditLog view so targetedms-create.sql (runs after this script) rebuilds it with the fixed recursive CTE.
SELECT core.fn_dropifexists('AuditLog', 'targetedms', 'VIEW', NULL);

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.

This shouldn't be necessary, though it's harmless. Just the version bump should be enough to trigger the drop/create pair.

@ankurjuneja ankurjuneja merged commit 4cf5bd2 into release26.3-SNAPSHOT Jul 6, 2026
7 of 8 checks passed
@ankurjuneja ankurjuneja deleted the 26.3_fb_fixAuditLogContainerScopingTest branch July 6, 2026 20:32
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.

2 participants