Skip to content

response body from image+url request for better error reporting #2334#2350

Merged
merks merged 1 commit into
eclipse-birt:masterfrom
mithrandirii:master
Jun 9, 2026
Merged

response body from image+url request for better error reporting #2334#2350
merks merged 1 commit into
eclipse-birt:masterfrom
mithrandirii:master

Conversation

@mithrandirii

@mithrandirii mithrandirii commented Dec 15, 2025

Copy link
Copy Markdown
Contributor

Added response body to failed responses in ResourceLocatorWrapper #2334

@mithrandirii mithrandirii changed the title WIP: response body from image+url request for better error reporting #2334 response body from image+url request for better error reporting #2334 Dec 15, 2025

@hvbtup hvbtup 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.

I don't know if this routine can also be called for other types of URLs, eg file URLs.
I think the error body "No HTTP-Protocol" is useless and even misleading in this case.
extractErrorBody should only be called for HTTP protocols.

@mithrandirii

Copy link
Copy Markdown
Contributor Author

@hvbtup valid point, i changed the pull-request

@merks

merks commented Dec 17, 2025

Copy link
Copy Markdown
Contributor

@mithrandirii

This seems fine. Could you please share what the resulting error looks like?

@wimjongman

Copy link
Copy Markdown
Contributor

@mithrandirii

This seems fine. Could you please share what the resulting error looks like?

@mithrandirii Can you please respond?

@wimjongman wimjongman added this to the 4.23 milestone Feb 12, 2026
@wimjongman wimjongman modified the milestones: 4.23, 4.24 Mar 11, 2026
@wimjongman

Copy link
Copy Markdown
Contributor

Moved to 4.24

@wimjongman

Copy link
Copy Markdown
Contributor

Closed. Author @mithrandirii does not respond.

@wimjongman wimjongman closed this Jun 8, 2026
@mithrandirii

Copy link
Copy Markdown
Contributor Author

@wimjongman sorry to not respond. i was off for a long time. the email from github reminded me.
we still need this change. is there any chance to get this into 4.24? in the next message i will respond to the answer from @merks

@mithrandirii

mithrandirii commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

the log message without the change is:

Jun 08, 2026 7:44:51 PM org.eclipse.birt.report.engine.util.ResourceLocatorWrapper findResource
WARNING: http://localhost:3080/logo/test/logo.svg is not accessible.

and with the change:

Jun 08, 2026 7:39:10 PM org.eclipse.birt.report.engine.util.ResourceLocatorWrapper findResource
WARNING: http://localhost:3080/logo/test/logo.svg is not accessible.
java.io.IOException: {"success":false,"message":"logo not found"}
	at org.eclipse.birt.report.engine.util.ResourceLocatorWrapper.findResource(ResourceLocatorWrapper.java:97)
	at org.eclipse.birt.report.engine.emitter.ImageReader.readImage(ImageReader.java:260)
	at org.eclipse.birt.report.engine.emitter.ImageReader.readImage(ImageReader.java:250)
	at org.eclipse.birt.report.engine.emitter.ImageReader.read(ImageReader.java:129)
	at org.eclipse.birt.report.engine.nLayout.area.impl.ImageAreaLayout.initialize(ImageAreaLayout.java:93)
	at org.eclipse.birt.report.engine.nLayout.area.impl.ImageAreaLayout.layout(ImageAreaLayout.java:84)
	at org.eclipse.birt.report.engine.nLayout.LayoutEngine.startContent(LayoutEngine.java:426)
	at org.eclipse.birt.report.engine.emitter.ContentEmitterAdapter.startImage(ContentEmitterAdapter.java:181)
	at org.eclipse.birt.report.engine.emitter.ContentEmitterUtil.startContent(ContentEmitterUtil.java:86)
	at org.eclipse.birt.report.engine.layout.html.buffer.HTMLPageBuffer.startContent(HTMLPageBuffer.java:102)
	at org.eclipse.birt.report.engine.layout.html.buffer.TableBreakBuffer.startContent(TableBreakBuffer.java:226)
	at org.eclipse.birt.report.engine.layout.html.HTMLLeafItemLM.start(HTMLLeafItemLM.java:65)
	at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:132)
	at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:66)
	at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.layout(HTMLPageLM.java:92)
	at org.eclipse.birt.report.engine.layout.html.HTMLReportLayoutEngine.layout(HTMLReportLayoutEngine.java:97)
	at org.eclipse.birt.report.engine.presentation.ReportDocumentBuilder.build(ReportDocumentBuilder.java:226)
	at org.eclipse.birt.report.engine.api.impl.RunTask.doRun(RunTask.java:224)
	at org.eclipse.birt.report.engine.api.impl.RunTask.run(RunTask.java:108)
	at org.eclipse.birt.report.designer.ui.preview.editors.AbstractViewer.createReportDocument(AbstractViewer.java:90)
	at org.eclipse.birt.report.designer.ui.viewer.StaticHTMLViewer.renderReport(StaticHTMLViewer.java:666)
	at org.eclipse.birt.report.designer.ui.viewer.StaticHTMLViewer$16.work(StaticHTMLViewer.java:761)
	at org.eclipse.birt.report.designer.ui.viewer.job.AbstractJob.run(AbstractJob.java:48)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

the string "{"success":false,"message":"logo not found"}" is the html body of a example http image resource

@mithrandirii

mithrandirii commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

to get this working correctly i had to add two futher lines. i added it to my fork, but i don't know how to update the pr. maybe it only works for open pull-requests

@merks

merks commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Amend the commit and force push it. There is one day left to close off the 4.24 release

@merks merks reopened this Jun 8, 2026
@merks

merks commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

And be sure to rebase in master or the build will definitely fail.

@mithrandirii

Copy link
Copy Markdown
Contributor Author

big thx for reopening the pr!

if i look to files changed tab all commits are included.

one check was cancelled:

build
Canceling since a higher priority waiting request for refs/pull/2350/merge exists

CI
Canceling since a higher priority waiting request for refs/pull/2350/merge exists

but i don't understand why! soory, what do i need to do?

@wimjongman

Copy link
Copy Markdown
Contributor

@copilot review security implications.

@merks

merks commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

This commit chain is kind of a mess now. I don’t want to merge it in this form. If you’re not sure how to squash a single commit rebased on master, then maybe check out master, pull, and create a new branch that you push to your fork for a new pull request. I can have a look tomorrow, but it’s too late in the day for me.

@mithrandirii

Copy link
Copy Markdown
Contributor Author

ok, i think i have it now. thx again for the support!

@merks merks 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.

Looks okay, though for me testing with a broken link, the error stream does not contain anything useful:

image

More of concern is that if the connection isn't a URL connection, for which disconnect is called, the stream itself is not closed. I imagine disconnect closes it, but that's not called in all cases. I think that should be better guarded.

Better safe than sorry:

				try {
					connection = url.openConnection();
					try (InputStream in = connection.getInputStream()) {
						inBytes = getByteArrayFromInputStream(in);
						cache.put(url, inBytes);
					}
				} catch (IOException e) {

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Enhances BIRT report engine resource loading diagnostics by attaching HTTP response bodies (when available) to warning logs for failed URL-based resource retrievals, improving troubleshooting for dynamic image URL failures (Issue #2334).

Changes:

  • Switches URL resource retrieval from url.openStream() to an explicit URLConnection to enable access to HTTP error streams.
  • Logs failures via a LogRecord to preserve i18n message formatting while optionally attaching a throwable containing response-body details.
  • Adds helper logic to extract and truncate HTTP error response bodies.

@mithrandirii

Copy link
Copy Markdown
Contributor Author

i implemented changerequests from @merks and copilot.

the resulting message looks like this now:

Jun 09, 2026 9:23:55 AM org.eclipse.birt.report.engine.util.ResourceLocatorWrapper findResource
WARNING: http://localhost:3080/logo/test/logo.svg is not accessible.
java.io.IOException: {"success":false,"message":"logo not found"}
	at org.eclipse.birt.report.engine.util.ResourceLocatorWrapper.findResource(ResourceLocatorWrapper.java:97)
	at org.eclipse.birt.report.engine.emitter.ImageReader.readImage(ImageReader.java:260)
	at org.eclipse.birt.report.engine.emitter.ImageReader.readImage(ImageReader.java:250)
	at org.eclipse.birt.report.engine.emitter.ImageReader.read(ImageReader.java:129)
	at org.eclipse.birt.report.engine.nLayout.area.impl.ImageAreaLayout.initialize(ImageAreaLayout.java:93)
	at org.eclipse.birt.report.engine.nLayout.area.impl.ImageAreaLayout.layout(ImageAreaLayout.java:84)
	at org.eclipse.birt.report.engine.nLayout.LayoutEngine.startContent(LayoutEngine.java:426)
	at org.eclipse.birt.report.engine.emitter.ContentEmitterAdapter.startImage(ContentEmitterAdapter.java:181)
	at org.eclipse.birt.report.engine.emitter.ContentEmitterUtil.startContent(ContentEmitterUtil.java:86)
	at org.eclipse.birt.report.engine.layout.html.buffer.HTMLPageBuffer.startContent(HTMLPageBuffer.java:102)
	at org.eclipse.birt.report.engine.layout.html.buffer.TableBreakBuffer.startContent(TableBreakBuffer.java:226)
	at org.eclipse.birt.report.engine.layout.html.HTMLLeafItemLM.start(HTMLLeafItemLM.java:65)
	at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:132)
	at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:66)
	at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.layout(HTMLPageLM.java:92)
	at org.eclipse.birt.report.engine.layout.html.HTMLReportLayoutEngine.layout(HTMLReportLayoutEngine.java:97)
	at org.eclipse.birt.report.engine.presentation.ReportDocumentBuilder.build(ReportDocumentBuilder.java:226)
	at org.eclipse.birt.report.engine.api.impl.RunTask.doRun(RunTask.java:224)
	at org.eclipse.birt.report.engine.api.impl.RunTask.run(RunTask.java:108)
	at org.eclipse.birt.report.designer.ui.preview.editors.AbstractViewer.createReportDocument(AbstractViewer.java:90)
	at org.eclipse.birt.report.designer.ui.viewer.StaticHTMLViewer.renderReport(StaticHTMLViewer.java:666)
	at org.eclipse.birt.report.designer.ui.viewer.StaticHTMLViewer$16.work(StaticHTMLViewer.java:761)
	at org.eclipse.birt.report.designer.ui.viewer.job.AbstractJob.run(AbstractJob.java:48)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:3080/logo/bimme/logo.svg
	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:2028)
	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1629)
	at org.eclipse.birt.report.engine.util.ResourceLocatorWrapper.findResource(ResourceLocatorWrapper.java:84)
	... 23 more

@wimjongman

Copy link
Copy Markdown
Contributor

@mithrandirii please resolve the conversations that you have implemented.

@merks

merks commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

And please amend the commit and force push it, because we again have 3 commits. We don't want the intermediate stages commit to the repository and we don't want to use squash and merge because it mess up the committer email to be some github bot thing. So this should be a single commit...

@mithrandirii

Copy link
Copy Markdown
Contributor Author

ok, @wimjongman: resolved the conversations and @merks force-pushed to one commit

@merks merks 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.

Looks better. Thanks!

@merks

merks commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

@wimjongman

I assume we are comfortable merging this before a final milestone build today?

@wimjongman

Copy link
Copy Markdown
Contributor

@wimjongman

I assume we are comfortable merging this before a final milestone build today?

Yes, please go ahead.

@wimjongman wimjongman linked an issue Jun 9, 2026 that may be closed by this pull request
@merks merks merged commit 78c41fd into eclipse-birt:master Jun 9, 2026
3 checks passed
@mithrandirii

Copy link
Copy Markdown
Contributor Author

big thx to all for the support and the merge before the release

@merks

merks commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

A nightly build has been twigged and when that''s done I will trigger a milestone build which is the release candidate for tomorrow.

@wimjongman

Copy link
Copy Markdown
Contributor

Thanks Ed @merks, and thank you for the patch @mithrandirii.

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.

response body from image+url request for better error reporting

5 participants