Skip to content

Conversation

roddhjav
Copy link

@roddhjav roddhjav commented Aug 20, 2025

What changes were proposed in this pull request?

In spark web, the application name need to be escaped.

Why are the changes needed?

Not escaped app name could lead to bad thing in the web ui

Does this PR introduce any user-facing change?

No

How was this patch tested?

Tests already exist, it was manually tested.

Was this patch authored or co-authored using generative AI tooling?

No

@github-actions github-actions bot added the CORE label Aug 20, 2025
@xuanyuanking
Copy link
Member

The code looks good and straightforward, could you answer the questions in PR description?

Copy link
Member

@xuanyuanking xuanyuanking left a comment

Choose a reason for hiding this comment

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

LGTM

will merge after finishing the PR description

@roddhjav
Copy link
Author

Done

@LuciferYang
Copy link
Contributor

https://github.com/apache/spark/pull/52084/checks?check_run_id=48507003442

image

It seems that the Github Actions has not been executed yet.

@roddhjav
Copy link
Author

My bad, fixed

@LuciferYang
Copy link
Contributor

https://github.com/roddhjav/spark/actions/runs/17212259314/job/48827031130

Could you retrigger the failed GA task? @roddhjav

@roddhjav
Copy link
Author

roddhjav commented Aug 26, 2025

Done, one of the tests keeps failing. However, it does not look like it is related with this PR.

Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

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

Could you provide a valid test case to protect your contribution from a future regression, please, @roddhjav ?

@@ -345,7 +346,7 @@ class SparkConf(loadDefaults: Boolean)

/** Set a name for your application. Shown in the Spark web UI. */
def setAppName(name: String): SparkConf = {
set("spark.app.name", name)
set("spark.app.name", StringEscapeUtils.escapeHtml4(name))
Copy link
Member

@dongjoon-hyun dongjoon-hyun Aug 26, 2025

Choose a reason for hiding this comment

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

I'm not sure this is a safe change. Since spark.app.name is used in many places inside and outside of Apache Spark, this kind of implicit change may cause significant breaking changes due to the mismatches.

Let me ask in this way: if we throws Exception here, do you think it's okay? IMO, it's a breaking change, isn't it?

From my side, I'd like to recommend @roddhjav to escape in WebUI part (during HTML generation) instead of taking a risk to affect all Spark ecosystem.

Copy link
Contributor

@mridulm mridulm Aug 27, 2025

Choose a reason for hiding this comment

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

Agree with @dongjoon-hyun.
Instead, it would be better to simply escape this in Spark UI, so that what gets returned works for html (note, not for REST calls - just the html).

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

Copy link
Contributor

Choose a reason for hiding this comment

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

In addition, I'd like to confirm whether the escaped "app name" (if it has been escaped) will affect the search functionality on the job list page in Yarn mode, and whether it is necessary to use the escaped app name for searching instead?

@dongjoon-hyun
Copy link
Member

cc @cloud-fan , @mridulm , @yaooqinn too.

@yaooqinn
Copy link
Member

yaooqinn commented Aug 28, 2025

Not escaped app name could lead to bad thing in the web ui

Can you show us a bad case you've met?

Based on a local test below, it looks like the AS-IS behavior makes sense to me without escaping.

scala> org.apache.commons.text.StringEscapeUtils.escapeHtml4("ß")
val res0: String = ß

bin/spark-shell --name ß

image image

bin/spark-shell --name 'ß'

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants