This is an automated email from the ASF dual-hosted git repository.
nchammas pushed a commit to branch branch-4.3
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/branch-4.3 by this push:
new cb0a40233889 [MINOR][DOC] Fix broken HTML table in
sql-error-conditions caused by placeholders inside code spans
cb0a40233889 is described below
commit cb0a402338894ec24e6e80f441d45122293ab7d5
Author: anshulbhide <[email protected]>
AuthorDate: Thu Oct 8 20:55:05 2026 +0300
[MINOR][DOC] Fix broken HTML table in sql-error-conditions caused by
placeholders inside code spans
### What changes were proposed in this pull request?
`docs/_plugins/build-error-docs.py` builds the table on the
`sql-error-conditions` page from `error-conditions.json`. Its
`assemble_message` wraps every `<placeholder>` token in backticks before
rendering the message as Markdown, so that placeholders render as code with
escaped angle brackets.
That substitution does not check whether the placeholder is already inside
an inline code span. For a message such as
```
Update the literal in `APPROX NEAREST <numResults> BY ...` (or `EXACT
NEAREST <numResults> BY ...`)
```
it produces `` `APPROX NEAREST `<numResults>` BY ...` ``, which Markdown
reads as two short code spans with a bare `<numResults>` between them. That
token reaches the generated HTML as a raw tag, the browser treats it as an
element, and the auto-closing logic breaks the surrounding `<table>` (a stray
`</table>` appears before the table and the rest of the page is nested inside
the row).
This PR changes the substitution to match inline code spans first and leave
them untouched, so only bare placeholders are wrapped:
```python
cleaned_message = re.sub(
r"`[^`]*`|(<.*?>)",
lambda x: x.group(0) if x.group(1) is None else f"`{x.group(1)}`",
message,
)
```
Two messages on `master` trigger the bug today:
`NEAREST_BY_JOIN.NUM_RESULTS_OUT_OF_RANGE` and
`INVALID_UDF_PARAMETER_PLACEHOLDER_INDEX`. Any future message that puts a
placeholder mid-span would trigger it too, so the fix is in the generator
rather than in the JSON.
### Why are the changes needed?
The published page
https://spark.apache.org/docs/latest/sql-error-conditions.html renders with a
broken table and the affected messages lose text (`APPROX NEAREST BY ...`
instead of `APPROX NEAREST <numResults> BY ...`). Reported in #58094. #58158 by
hulincup proposes an equivalent fix (stashing code spans and restoring them
after the substitution) and was approved, but has been waiting a month on
removing two screenshot files; this PR is the same one-function change with a
single reg [...]
### Does this PR introduce _any_ user-facing change?
No. Documentation build only.
### How was this patch tested?
Ran the generator on `master` before and after the change (it only needs
`mkdocs` installed) and diffed the output:
```
python3 -m venv /tmp/docsenv && /tmp/docsenv/bin/pip install mkdocs
/tmp/docsenv/bin/python docs/_plugins/build-error-docs.py
```
- Before: the output contains raw `<numResults>` (x2), `<index>` (x2) and
`<numParams>` (x1) tags; parsing it with `html.parser` reports those three
unexpected, unclosed element names.
- After: those tags are gone and render as
`<code><numResults></code>` etc. The parser reports no unexpected tags
and every element balanced; the row and cell counts are unchanged (1703 `<tr>`,
5106 `<td>`).
- The only lines that differ between the two outputs are the two affected
message cells.
Before:
```html
<code>APPROX NEAREST</code><numResults><code>BY ...</code>
```
After:
```html
<code>APPROX NEAREST <numResults> BY ...</code>
```
No test was added: the docs plugins have no test suite, and the generator
is exercised by the docs build.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Fable 5.1)
Closes #59010 from anshulbhide/fix-error-docs-code-span-placeholders.
Authored-by: anshulbhide <[email protected]>
Signed-off-by: Nicholas Chammas <[email protected]>
(cherry picked from commit 8d290dc1ca7676a448dfd97b0c75fa9a95aa8df8)
Signed-off-by: Nicholas Chammas <[email protected]>
---
docs/_plugins/build-error-docs.py | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/docs/_plugins/build-error-docs.py
b/docs/_plugins/build-error-docs.py
index 068ec0da50c9..2acdd862c059 100644
--- a/docs/_plugins/build-error-docs.py
+++ b/docs/_plugins/build-error-docs.py
@@ -22,7 +22,14 @@ ERROR_CONDITIONS_PATH = (
def assemble_message(message_parts):
message = " ".join(message_parts)
- cleaned_message = re.sub(r"(<.*?>)", lambda x: f"`{x.group(1)}`", message)
+ # If a message section contains backticks (e.g. `APPROX NEAREST
<numResults> BY ...`),
+ # keep it as-is. Otherwise, wrap <placeholder> tags with backticks so they
are not
+ # interpreted as HTML tags.
+ cleaned_message = re.sub(
+ r"`[^`]*`|(<.*?>)",
+ lambda x: x.group(0) if x.group(1) is None else f"`{x.group(1)}`",
+ message,
+ )
return markdown.markdown(cleaned_message)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]