This is an automated email from the ASF dual-hosted git repository.

zhengruifeng pushed a commit to branch branch-4.x
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-4.x by this push:
     new baad4b180b86 [SPARK-33552][UI] Declare document language in Spark UI 
pages
baad4b180b86 is described below

commit baad4b180b8698d487df3628b202bcbdd1f55cd3
Author: Aditya Vaish <[email protected]>
AuthorDate: Wed Nov 11 09:30:50 2026 +0800

    [SPARK-33552][UI] Declare document language in Spark UI pages
    
    ### What changes were proposed in this pull request?
    
    Add `lang="en"` to the root `<html>` element emitted by both shared Spark 
UI page templates, `headerSparkPage` and `basicSparkPage`.
    
    Add a regression test in `UIUtilsSuite` that renders both templates and 
asserts that each root element declares English as the document language.
    
    ### Why are the changes needed?
    
    [SPARK-33552](https://issues.apache.org/jira/browse/SPARK-33552) reports 
that Spark History Server pages lack a document language. Without a `lang` 
attribute, screen readers cannot reliably determine the language to use when 
reading the page.
    
    The shared templates render English UI text. Declaring that language fixes 
the accessibility metadata for pages using either template, without changing 
their layout or content.
    
    ### Does this PR introduce _any_ user-facing change?
    
    Yes. Pages generated by the shared Spark UI templates now declare 
`lang="en"`, allowing screen readers to identify the document language. 
Previously, neither template included a language attribute. Visual appearance 
is unchanged.
    
    ### How was this patch tested?
    
    Added `SPARK-33552: Spark UI pages declare their document language` to 
`UIUtilsSuite`, covering both shared page templates.
    
    The following commands passed using Temurin Java 21.0.13:
    
    ```sh
    build/sbt 'core/testOnly org.apache.spark.ui.UIUtilsSuite'
    build/sbt 'core/scalastyle' 'core/Test/scalastyle'
    ```
    
    All 10 tests in `UIUtilsSuite` passed. Both Scala style checks reported 
zero errors and zero warnings. `git diff --check` also passed.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    Generated-by: GitHub Copilot App 1.0.102-0.unstable.r41779900948.gf482387
    
    This patch was authored with generative AI assistance from GitHub Copilot, 
powered by GPT-6.1 Sol. AI assistance was used to investigate the issue, 
implement the language attributes and regression test, run validation, and 
draft this pull request description.
    
    Closes #60146 from adityavaish/spark-33552-ui-language.
    
    Lead-authored-by: Aditya Vaish 
<[email protected]>
    Co-authored-by: Aditya Vaish <[email protected]>
    Signed-off-by: Ruifeng Zheng <[email protected]>
    
    (cherry picked from commit 2a591011496c896e00080a4781648618802f09d1)
    Signed-off-by: Ruifeng Zheng <[email protected]>
    
    
    skip-checks: true
---
 .../src/main/scala/org/apache/spark/ui/UIUtils.scala |  4 ++--
 .../scala/org/apache/spark/ui/UIUtilsSuite.scala     | 20 ++++++++++++++++++++
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/core/src/main/scala/org/apache/spark/ui/UIUtils.scala 
b/core/src/main/scala/org/apache/spark/ui/UIUtils.scala
index 273bfb661fa1..afccf4762865 100644
--- a/core/src/main/scala/org/apache/spark/ui/UIUtils.scala
+++ b/core/src/main/scala/org/apache/spark/ui/UIUtils.scala
@@ -283,7 +283,7 @@ private[spark] object UIUtils extends Logging {
     }
     val helpButton: Seq[Node] = helpText.map(tooltip(_, 
"top")).getOrElse(Seq.empty)
 
-    <html data-bs-theme="light">
+    <html lang="en" data-bs-theme="light">
       <head>
         {commonHeaderNodes(request)}
         <script nonce={CspNonce.get}>{Unparsed(
@@ -360,7 +360,7 @@ private[spark] object UIUtils extends Logging {
       title: String,
       useDataTables: Boolean = false,
       useTimeline: Boolean = false): Seq[Node] = {
-    <html data-bs-theme="light">
+    <html lang="en" data-bs-theme="light">
       <head>
         {commonHeaderNodes(request)}
         <script nonce={CspNonce.get}>{Unparsed(
diff --git a/core/src/test/scala/org/apache/spark/ui/UIUtilsSuite.scala 
b/core/src/test/scala/org/apache/spark/ui/UIUtilsSuite.scala
index 50b0f34c4bd8..66a9bf816cb9 100644
--- a/core/src/test/scala/org/apache/spark/ui/UIUtilsSuite.scala
+++ b/core/src/test/scala/org/apache/spark/ui/UIUtilsSuite.scala
@@ -20,11 +20,31 @@ package org.apache.spark.ui
 import scala.xml.{Node, Text}
 import scala.xml.Utility.trim
 
+import jakarta.servlet.http.HttpServletRequest
+import org.mockito.Mockito.{mock, when}
+
 import org.apache.spark.{ErrorMessageFormat, SparkException, SparkFunSuite, 
SparkThrowableHelper}
 
 class UIUtilsSuite extends SparkFunSuite {
   import UIUtils._
 
+  test("SPARK-33552: Spark UI pages declare their document language") {
+    val request = mock(classOf[HttpServletRequest])
+    val tab = mock(classOf[SparkUITab])
+    when(tab.appName).thenReturn("test")
+    when(tab.basePath).thenReturn("")
+    when(tab.headerTabs).thenReturn(Seq.empty)
+
+    val pages = Seq(
+      headerSparkPage(request, "test", Seq.empty, tab),
+      basicSparkPage(request, Seq.empty, "test"))
+
+    pages.foreach { page =>
+      assert(page.head.label === "html")
+      assert((page.head \@ "lang") === "en")
+    }
+  }
+
   test("makeDescription(plainText = false)") {
     verify(
       """test <a href="/link"> text </a>""",


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to