Skip to content

fix(logging): migrate logback <if condition> attribute to <condition> element - #19375

Open
chakru-r wants to merge 2 commits into
masterfrom
fix-logback-conditional-aggregator-gate
Open

fix(logging): migrate logback <if condition> attribute to <condition> element#19375
chakru-r wants to merge 2 commits into
masterfrom
fix-logback-conditional-aggregator-gate

Conversation

@chakru-r

@chakru-r chakru-r commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Problem

Setting LOG_AGGREGATOR_ENDPOINT has no effect. The optional Loki log-shipping appender is never created, and nothing is logged to indicate why — logback reports the underlying cause as a deprecation warning rather than an error, so the feature fails silently.

Console logging is not affected: STDOUT is defined unconditionally in all of these files.

Root cause

Logback stopped evaluating the condition attribute on <if> somewhere between 1.5.32 and 1.5.37. In 1.5.38 (the version pinned in build.gradle), the only consumer of IfModel.getCondition() is the deprecation warning:

// IfModelHandler.handle()
String conditionStr = ifModel.getCondition();
emitDeprecationWarningIfNecessary(conditionStr);   // ...and that is all it does
if (micTopObject instanceof BranchState) { ... }   // state comes from a <condition> handler

In the attribute form nothing pushes that BranchState, so IfModel.branchState stays null, and both ThenModelHandler and ElseModelHandler call deepMarkAsSkipped(). Neither branch executes, so the AGGREGATOR appender is never instantiated and never attached to <root>.

Because the compose profiles default the variable to empty (LOG_AGGREGATOR_ENDPOINT: ${LOG_AGGREGATOR_ENDPOINT:-}), no CI job ever takes the branch, which is why this went unnoticed.

Logback's docs describe the attribute as deprecated with removal scheduled for January 2027, so this migration is needed regardless of the current breakage.

Fix

Replace the gate in all six logback.xml files with the supported <condition> element, which precedes <if> rather than nesting inside it, using the built-in Janino-free ExpressionPropertyCondition:

<condition class="ch.qos.logback.core.boolex.ExpressionPropertyCondition">
    <expression>isDefined("LOG_AGGREGATOR_ENDPOINT") &amp;&amp; !propertyEquals("LOG_AGGREGATOR_ENDPOINT", "")</expression>
</condition>
<if>
    <then>
        <appender name="AGGREGATOR" ...>
before (no longer evaluated) after
!property("LOG_AGGREGATOR_ENDPOINT").isEmpty() isDefined("LOG_AGGREGATOR_ENDPOINT") && !propertyEquals("LOG_AGGREGATOR_ENDPOINT", "")

property() returns "" for an unset key, so both clauses are required — propertyEquals alone returns false for an unset key, which would invert the meaning of the gate. && is written &amp;&amp; because & is reserved in XML.

Verification

Ran each of the six config files on logback 1.5.38 in a standalone harness (real configs, janino 3.0.12 as pinned, the Loki appender on the classpath), emitting one INFO event per configured logger and then inspecting root.iteratorForAppenders():

LOG_AGGREGATOR_ENDPOINT before after
unset no AGGREGATOR no AGGREGATOR
empty string no AGGREGATOR no AGGREGATOR
http://host:port no AGGREGATOR AGGREGATOR attached ✅

Console output (event counts and formatting) is unchanged in every case, for all six services — gms, mae-consumer, mce-consumer, datahub-upgrade, and both frontend configs.

Checklist

Note for reviewers

This class of failure is silent by design on logback's side. A cheap guard would be a test that parses each logback.xml and asserts logback's StatusManager reports zero errors and that expected appenders are attached — worth considering separately, since the same footgun applies to any future <if> usage.

🤖 Generated with Claude Code


Summary by cubic

Restores Loki log-shipping by migrating Logback conditionals from deprecated <if condition="..."> to a preceding <condition> element. On 1.5.38 the attribute was ignored, so LOG_AGGREGATOR_ENDPOINT had no effect and the AGGREGATOR appender was never created; now the gate evaluates and attaches the appender only when the variable is set.

  • Updates all six logback.xml files (frontend conf/run, datahub-upgrade, mae-consumer, mce-consumer, metadata-service).
  • Uses ch.qos.logback.core.boolex.ExpressionPropertyCondition with isDefined("LOG_AGGREGATOR_ENDPOINT") && !propertyEquals("LOG_AGGREGATOR_ENDPOINT", ""); <condition> must precede <if>.
  • Behavior: console STDOUT unchanged; AGGREGATOR attaches only when LOG_AGGREGATOR_ENDPOINT is non-empty.
  • Docs: updates docs/how/updating-datahub.md to warn that 1.5.37+ ignores <if condition="..."> and that <condition> cannot be inside an <appender>, <logger>, or <root>; no action if using bundled configs, migrate custom files accordingly.

Written for commit 4c4af78. Summary will update on new commits.

Review in cubic

… element

Logback stopped evaluating the `condition` attribute on <if> somewhere between
1.5.32 and 1.5.37. In 1.5.38, IfModelHandler only emits a deprecation warning
and takes its branch state from an object pushed by a separate <condition>
handler; the attribute form pushes nothing, so IfModel.branchState stays null
and both ThenModelHandler and ElseModelHandler call deepMarkAsSkipped().

Neither branch runs, so the optional Loki log-shipping appender is never
created: setting LOG_AGGREGATOR_ENDPOINT has no effect, and because logback
reports this as a deprecation warning rather than an error, the feature fails
silently. Console logging is unaffected, since STDOUT is defined
unconditionally.

Replace the gate with the supported <condition> element, which must precede
<if> rather than nest inside it, using the built-in Janino-free
ExpressionPropertyCondition:

  !property("LOG_AGGREGATOR_ENDPOINT").isEmpty()
    -> isDefined("LOG_AGGREGATOR_ENDPOINT")
       && !propertyEquals("LOG_AGGREGATOR_ENDPOINT", "")

property() returns "" for an unset key, so both clauses are required:
propertyEquals alone returns false for an unset key, which would invert the
meaning of the gate.

Verified on logback 1.5.38 against all six config files: AGGREGATOR attaches to
root only when LOG_AGGREGATOR_ENDPOINT is set to a non-empty value, and console
output is byte-identical in every case.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@cursor

cursor Bot commented Aug 21, 2026

Copy link
Copy Markdown

PR Summary

Overview
Restores optional Loki log shipping (LOG_AGGREGATOR_ENDPOINT) that silently stopped working after Logback 1.5.37+ ignored the deprecated condition attribute on <if>.

All six service logback.xml files now use a preceding <condition> with ExpressionPropertyCondition so the AGGREGATOR appender attaches only when the endpoint is defined and non-empty. Console logging is unchanged.

Upgrade notes document the same syntax change for operators who mount a custom logback.xml.

Reviewed by Cursor Bugbot for commit 4c4af78. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot added product PR or Issue related to the DataHub UI/UX devops PR or Issue related to DataHub backend & deployment labels Aug 21, 2026
@alwaysmeticulous

alwaysmeticulous Bot commented Aug 21, 2026

Copy link
Copy Markdown

✅ Meticulous spotted 0 visual differences across 1085 screens tested: view results.

Meticulous evaluated ~10 hours of user flows against your PR.

Expected differences? Click here. Last updated for commit 4c4af78 docs(updating): record the logback conditional migration under Next. This comment will update as new commits are pushed.

@cubic-dev-ai cubic-dev-ai Bot 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.

1 issue found across 6 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="datahub-upgrade/src/main/resources/logback.xml">

<violation number="1" location="datahub-upgrade/src/main/resources/logback.xml:91">
P1: Custom agent: **Flag Security Vulnerabilities**

When `LOG_AGGREGATOR_ENDPOINT` is set to an `http://` URL, this new condition activates `Loki4jAppender`, which sends logs over plaintext HTTP. Require and validate an `https://` endpoint before attaching the appender.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

push API under that prefix rather than at the bare path. -->
<if condition='!property("LOG_AGGREGATOR_ENDPOINT").isEmpty()'>
<condition class="ch.qos.logback.core.boolex.ExpressionPropertyCondition">
<expression>isDefined("LOG_AGGREGATOR_ENDPOINT") &amp;&amp; !propertyEquals("LOG_AGGREGATOR_ENDPOINT", "")</expression>

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.

P1: Custom agent: Flag Security Vulnerabilities

When LOG_AGGREGATOR_ENDPOINT is set to an http:// URL, this new condition activates Loki4jAppender, which sends logs over plaintext HTTP. Require and validate an https:// endpoint before attaching the appender.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At datahub-upgrade/src/main/resources/logback.xml, line 91:

<comment>When `LOG_AGGREGATOR_ENDPOINT` is set to an `http://` URL, this new condition activates `Loki4jAppender`, which sends logs over plaintext HTTP. Require and validate an `https://` endpoint before attaching the appender.</comment>

<file context>
@@ -87,7 +87,10 @@
          push API under that prefix rather than at the bare path. -->
-    <if condition='!property("LOG_AGGREGATOR_ENDPOINT").isEmpty()'>
+    <condition class="ch.qos.logback.core.boolex.ExpressionPropertyCondition">
+        <expression>isDefined("LOG_AGGREGATOR_ENDPOINT") &amp;&amp; !propertyEquals("LOG_AGGREGATOR_ENDPOINT", "")</expression>
+    </condition>
+    <if>
</file context>

@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Initial JS bundle size ➡️

Gzipped
Base (933be3a) 3.09 MB
This PR 3.09 MB
Diff +0 KB (+0.0%)

Eager entry chunks (dist/assets/index-*.js) only. Codecov reports total bundle including lazy chunks — these intentionally differ.

@codecov

codecov Bot commented Aug 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@cubic-dev-ai cubic-dev-ai Bot 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.

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="docs/how/updating-datahub.md">

<violation number="1" location="docs/how/updating-datahub.md:88">
P3: The two entries describe the same 1.5.37+ behavior differently: line 86 says logback "silently ignores" the `condition` attribute, while line 88 says it "logs a deprecation warning" before skipping both branches. Only one can be right, and readers will rely on it to decide whether to watch the logs. Pick the accurate one and use it in both entries (if a deprecation warning is logged, change line 86's "silently ignores" to say the attribute is no longer honored and the failure is otherwise silent).</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread docs/how/updating-datahub.md Outdated
- **(Security / Dependencies)** Logback (`logback-classic` / `logback-core`) bumped from 1.5.32 to **1.5.38** for CVE-2026-9828 (`HardenedObjectInputStream` overly broad `java.lang`/`java.util` deserialization allowlist; fixed in 1.5.33+) and CVE-2026-10532 (Proxy class deserialization; fixed in 1.5.38). **Action:** none for operators; rebuild/redeploy picks up the new JARs. DataHub does not expose Logback `SimpleSocketServer` / `SimpleSSLSocketServer` by default.
- **(Security / Dependencies)** Logback (`logback-classic` / `logback-core`) bumped from 1.5.32 to **1.5.38** for CVE-2026-9828 (`HardenedObjectInputStream` overly broad `java.lang`/`java.util` deserialization allowlist; fixed in 1.5.33+) and CVE-2026-10532 (Proxy class deserialization; fixed in 1.5.38). **Action:** none for operators using the bundled logging config; rebuild/redeploy picks up the new JARs. If you supply your own `logback.xml` that uses `<if condition="...">`, see the #19375 entry below — 1.5.37+ silently ignores that attribute. DataHub does not expose Logback `SimpleSocketServer` / `SimpleSSLSocketServer` by default.

- #19375 **(Operations / logging)** Conditional blocks in `logback.xml` are evaluated again. Logback 1.5.37+ stopped honouring the `condition` attribute on `<if>`: it logs a deprecation warning and then skips both the `<then>` and the `<else>` branch, so the failure is silent. On `master` this left `LOG_AGGREGATOR_ENDPOINT` with no effect, because the optional Loki log-shipping appender was never created. No released version is affected — releases up to and including v1.7.0 ship Logback 1.5.32, which still evaluates the attribute. The bundled logging configs now use the supported `<condition>` element instead. **Action:** none if you use the bundled logging config. If you mount your own `logback.xml` containing `<if condition="...">`, those blocks are being ignored on 1.5.37+ — move the expression into a `<condition>` element placed immediately **before** the `<if>`:

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.

P3: The two entries describe the same 1.5.37+ behavior differently: line 86 says logback "silently ignores" the condition attribute, while line 88 says it "logs a deprecation warning" before skipping both branches. Only one can be right, and readers will rely on it to decide whether to watch the logs. Pick the accurate one and use it in both entries (if a deprecation warning is logged, change line 86's "silently ignores" to say the attribute is no longer honored and the failure is otherwise silent).

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At docs/how/updating-datahub.md, line 88:

<comment>The two entries describe the same 1.5.37+ behavior differently: line 86 says logback "silently ignores" the `condition` attribute, while line 88 says it "logs a deprecation warning" before skipping both branches. Only one can be right, and readers will rely on it to decide whether to watch the logs. Pick the accurate one and use it in both entries (if a deprecation warning is logged, change line 86's "silently ignores" to say the attribute is no longer honored and the failure is otherwise silent).</comment>

<file context>
@@ -83,7 +83,21 @@ Requirements:
-- **(Security / Dependencies)** Logback (`logback-classic` / `logback-core`) bumped from 1.5.32 to **1.5.38** for CVE-2026-9828 (`HardenedObjectInputStream` overly broad `java.lang`/`java.util` deserialization allowlist; fixed in 1.5.33+) and CVE-2026-10532 (Proxy class deserialization; fixed in 1.5.38). **Action:** none for operators; rebuild/redeploy picks up the new JARs. DataHub does not expose Logback `SimpleSocketServer` / `SimpleSSLSocketServer` by default.
+- **(Security / Dependencies)** Logback (`logback-classic` / `logback-core`) bumped from 1.5.32 to **1.5.38** for CVE-2026-9828 (`HardenedObjectInputStream` overly broad `java.lang`/`java.util` deserialization allowlist; fixed in 1.5.33+) and CVE-2026-10532 (Proxy class deserialization; fixed in 1.5.38). **Action:** none for operators using the bundled logging config; rebuild/redeploy picks up the new JARs. If you supply your own `logback.xml` that uses `<if condition="...">`, see the #19375 entry below — 1.5.37+ silently ignores that attribute. DataHub does not expose Logback `SimpleSocketServer` / `SimpleSSLSocketServer` by default.
+
+- #19375 **(Operations / logging)** Conditional blocks in `logback.xml` are evaluated again. Logback 1.5.37+ stopped honouring the `condition` attribute on `<if>`: it logs a deprecation warning and then skips both the `<then>` and the `<else>` branch, so the failure is silent. On `master` this left `LOG_AGGREGATOR_ENDPOINT` with no effect, because the optional Loki log-shipping appender was never created. No released version is affected — releases up to and including v1.7.0 ship Logback 1.5.32, which still evaluates the attribute. The bundled logging configs now use the supported `<condition>` element instead. **Action:** none if you use the bundled logging config. If you mount your own `logback.xml` containing `<if condition="...">`, those blocks are being ignored on 1.5.37+ — move the expression into a `<condition>` element placed immediately **before** the `<if>`:
+
+  ```xml
</file context>

Add a Next entry for the <if condition> -> <condition> migration, and correct
the Logback 1.5.38 bump entry's "Action: none for operators": anyone mounting
their own logback.xml that uses <if condition="..."> loses those blocks
silently on 1.5.37+, so that entry needed the caveat.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devops PR or Issue related to DataHub backend & deployment pending-submitter-merge product PR or Issue related to the DataHub UI/UX

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants