Skip to content

[api] Stop reading a server error message as a format string - #9454

Merged
JingsongLi merged 1 commit into
apache:masterfrom
plusplusjiajia:rest-error-message-not-a-format-string
Aug 29, 2026
Merged

[api] Stop reading a server error message as a format string#9454
JingsongLi merged 1 commit into
apache:masterfrom
plusplusjiajia:rest-error-message-not-a-format-string

Conversation

@plusplusjiajia

@plusplusjiajia plusplusjiajia commented Aug 28, 2026

Copy link
Copy Markdown
Member

Purpose

DefaultErrorHandler hands the server's error message to java.util.Formatter as syntax. When the message contains a %, the caller gets a formatting exception instead of the REST exception it waits for, and the
server's message is lost.

message: quota 80% exceeded
before : java.util.MissingFormatArgumentException: Format specifier '% e'
after : BadRequestException: quota 80% exceeded

Fixed:

  • NotAuthorizedException, ServiceFailureException, NotImplementedException, ServiceUnavailableException call super(String.format(message, args)) and RESTException formats again. The other four already pass
    super(message, args).
  • DefaultErrorHandler case 400 and case 501 pass the message as the format; the other seven branches pass "%s" with it as an argument.
  • RESTApi.getFunction passes "Invalid function name: " + name as the format, so a name rejected for containing % raises UnknownFormatConversionException.
  • RESTCatalog.listSystemTablesPaged does the same with a caught message, and drops its cause. RESTException has a cause-carrying constructor but no subclass exposes one, so this adds it to BadRequestException.

A sweep of every construction of these exceptions outside tests found no other site whose format argument is built from data.

@plusplusjiajia
plusplusjiajia force-pushed the rest-error-message-not-a-format-string branch from 81d8362 to 6e50b82 Compare August 28, 2026 17:37
@plusplusjiajia
plusplusjiajia marked this pull request as ready for review August 28, 2026 17:38
@JingsongLi

Copy link
Copy Markdown
Contributor

+1

@JingsongLi
JingsongLi merged commit 7873971 into apache:master Aug 29, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants