← Back to Pull requests

fix(admin): preserve omitted tag fields in descendant ancestry #8057

Merged
yangjj-iso merged 2 files (52 lines) on Oct 25, 2026 01:11 UTC
View on GitHub
yangjj-iso yangjj-iso commented on Oct 23, 2026 12:41 UTC
Author

Fixes #8027.

Description-only, name-only and parent-only tag updates preserve omitted fields in the database but previously rebuilt descendant ancestry with null values. Merge persisted name/description before propagating the effective tag. Null retains the persisted value; an explicit empty string remains an update.

Validation on Microsoft OpenJDK 17.0.18 through mvnw.cmd:

  • All 68 selected Tag* tests pass, including H2/MyBatis persistence, hierarchy moves and transaction rollback.

  • Seven partial-JSON regression cases cover omitted/null fields, empty description, parent moves/root promotion, multiple descendant levels and preserved refresh metadata. All seven fail with the fix removed and pass when restored.

  • The 28-module affected reactor passes compilation and Checkstyle. Root and changed-module Apache RAT and git diff --check pass.
  • Full repository and Docker E2E suites were not run.

    Diff: 52 lines (+52 / -0) across 2 files Reviewer: Aias00 Review duration: 2189m
    All Vouch review confidence checks passed
    Residual risk 0.05 = Change Risk (0.28) × (1 − Review Confidence (0.83)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.28 · 52 lines diff across 2 files
    0.28
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.82 · 1 substantive comment(s)
    0.82
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    82%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.238
    Real PR Conversation Timeline
    5 items
    Aias00 Aias00 commented on Oct 23, 2026 14:21 UTC
    Reviewer

    The preservation is correct and the asymmetry is deliberate, but it deserves a comment.

    Verified:

  • before is null-checked by Assert.notNull (line 98), so before.getTagName() / getTagDesc() cannot NPE.

  • java.util.Objects is already imported (line 42), and the test file already imports ObjectMapper, ParameterizedTest, ValueSource, assertNull and Objects, so both modules compile.

  • Since updateSubTags propagates tagDO, descendants now carry the preserved name/description in their ancestor chain — which is exactly what assertAncestor checks. The fix and the test agree.
  • One nit worth a line of comment:

    parentTagId falls back on StringUtils.isNotEmpty (so "" falls back to the stored value), while tagName / tagDesc fall back only on Objects.isNull (so "" is written as a real value). That is intentional — {"tagDesc":""} in the parameterized test asserts an explicit clear — but the two adjacent rules read as an oversight. A short comment on why tagDesc may be cleared while parentTagId may not would keep the next reader from "fixing" it.

    Not blocking.

    Aias00 Aias00 commented on code on Oct 24, 2026 04:13 UTC
    Code Review
    shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/TagServiceImpl.java:1
    @@ -102,6 +102,9 @@ public int update(final TagDTO tagDTO) {
             }
             TagDO tagDO = TagDO.buildTagDO(tagDTO);
             tagDO.setParentTagId(parentTagId);
    +        // Empty parent IDs retain the existing parent; an explicit empty name/description clears that field.

    The comment describes the parent-id rule, but it sits above the name/description assignments. Consider moving the parent half up next to setParentTagId (line 104) and keeping only "a null name/description retains the persisted value; an explicit empty string clears it" here, so each line documents the rule it implements.

    Aias00 Aias00 commented on Oct 24, 2026 04:13 UTC
    Reviewer

    Small, targeted, and verified.

    Verification I ran locally

  • Reverting just the three added lines (setName / setTagDesc) makes 7 of 17 cases in TagUpdateTransactionTest fail, which matches the seven partial-JSON cases the description claims; with the patch, TagUpdateTransactionTest + TagControllerTest are 24/24 green and checkstyle:check is clean on shenyu-admin.

  • before is read from the database at the top of update, so it is the persisted row, not the incoming DTO — the fallback is against real state.

  • The parentTagId handling directly above already had exactly this shape (isNotEmpty → fall back to before), so name/description now follow the pattern that was already established in the method instead of inventing a new one.

  • updateByPrimaryKeySelective would not have written nulls anyway; the observable damage was confined to the values updateSubTags embeds into descendant ext, which is precisely what the fix targets. Descendant refreshTime is preserved as asserted.

  • The test is self-contained: @BeforeEach re-inserts the four rows for every parameterized invocation and @AfterEach deletes them, so the mutations cannot leak between cases.
  • CI
    The only red jobs are shenyu-integrated-test-{http,grpc,combination,rewrite,https,sdk-http}, all failing on CachePluginTest.testMemoryModle / testRedisModle. The same two cases fail identically on #8076, which touches divide only, in the same time window — that is a master-level flake, not something this PR introduces.

    Aias00 Aias00 approved these changes on Oct 25, 2026 01:00 UTC
    Approved Reviewer

    The preservation logic is right, and the placement is right too: it runs after TagDO.buildTagDO and before updateSubTags, so the descendants' cached ancestor name/desc are rebuilt from the same values that are written to the row. before is already guarded by Assert.notNull, and Objects was already imported, so nothing else is needed.

    The parameterized test is the valuable part here — {"name":null,"tagDesc":null} and {} are the two cases that used to blank the columns, and asserting on both the row and the descendant ext is what makes it a real regression test rather than a mock check.

    One thing to be aware of, not a blocker: {"name":""} still writes an empty name, because TagDTO carries no constraints and the check is isNull, not isBlank. That matches the previous behaviour for an explicit empty string, so it is not a regression, but if an empty tag name is invalid the validation belongs on the DTO rather than here.

    Reviewers
    Assignees
    yangjj-iso yangjj-iso
    Labels
    risk: low confidence: 82.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 28.2% (LOW) · Higher = larger blast radius
    28.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 82.5% · Lower = rushed or shallow review
    82.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 4.9% · Safe to merge
    4.9%
    Repository