Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Issue while repairing - Internal Server Error:java.io.IOException: Command process failed with exit code 3 #2842

Closed
1 task done
hubdows opened this issue Feb 1, 2025 · 5 comments · Fixed by #2883
Assignees
Labels
Back End Issues related to back-end development

Comments

@hubdows
Copy link

hubdows commented Feb 1, 2025

Installation Method

Docker

The Problem

Trying to repair a PDF, the repair failed with the following error message:

Error
Internal Server Error:java.io.IOException: Command process failed with exit code 3. Error message: WARNING: /tmp/input_10795691053972271551.pdf: reported number of objects (4933) is not one plus the highest object number (4931) qpdf: there are warnings; original file kept in /tmp/input_10795691053972271551.pdf.~qpdf-orig qpdf: operation succeeded with warnings; resulting file may have some problems

While it says succeeded, the PDF appears to be unavailable for download.

Version of Stirling-PDF

3.3

Last Working Version of Stirling-PDF

No response

Page Where the Problem Occurred

http://192.168.1.200:8800/repair

Docker Configuration

version: '3.3'
services:
  stirling-pdf:
    image: stirlingtools/stirling-pdf:latest
    ports:
      - '8800:8080'
    volumes:
      - /volume1/docker/stirling-pdf/trainingData:/usr/share/tessdata #Required for extra OCR languages
      - /volume1/docker/stirling-pdf/extraConfigs:/configs
#      - ./customFiles:/customFiles/
#      - ./logs:/logs/
    environment:
      - DOCKER_ENABLE_SECURITY=false
      - INSTALL_BOOK_AND_ADVANCED_HTML_OPS=false
      - LANGS=en_GB

Relevant Log Output

java.io.IOException: Command process failed with exit code 3. Error message: WARNING: /tmp/input_10143437054679827769.pdf: reported number of objects (4933) is not one plus the highest object number (4931)
qpdf: there are warnings; original file kept in /tmp/input_10143437054679827769.pdf.~qpdf-orig
qpdf: operation succeeded with warnings; resulting file may have some problems
	at stirling.software.SPDF.utils.ProcessExecutor.runCommandWithOutputHandling(ProcessExecutor.java:236)
	at stirling.software.SPDF.utils.ProcessExecutor.runCommandWithOutputHandling(ProcessExecutor.java:133)
	at stirling.software.SPDF.controller.api.misc.RepairController.repairPdf(RepairController.java:62)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:257)
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:190)
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:118)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:986)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:891)
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1088)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:978)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014)
	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:914)
	at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:547)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:885)
	at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:614)
	at org.eclipse.jetty.ee10.servlet.ServletHolder.handle(ServletHolder.java:736)
	at org.eclipse.jetty.ee10.servlet.ServletHandler$ChainEnd.doFilter(ServletHandler.java:1619)
	at org.eclipse.jetty.ee10.websocket.servlet.WebSocketUpgradeFilter.doFilter(WebSocketUpgradeFilter.java:195)
	at org.eclipse.jetty.ee10.servlet.FilterHolder.doFilter(FilterHolder.java:205)
	at org.eclipse.jetty.ee10.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1591)
	at stirling.software.SPDF.config.MetricsFilter.doFilterInternal(MetricsFilter.java:48)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
	at org.eclipse.jetty.ee10.servlet.FilterHolder.doFilter(FilterHolder.java:205)
	at org.eclipse.jetty.ee10.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1591)
	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
	at org.eclipse.jetty.ee10.servlet.FilterHolder.doFilter(FilterHolder.java:205)
	at org.eclipse.jetty.ee10.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1591)
	at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
	at org.eclipse.jetty.ee10.servlet.FilterHolder.doFilter(FilterHolder.java:205)
	at org.eclipse.jetty.ee10.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1591)
	at org.springframework.web.filter.ServerHttpObservationFilter.doFilterInternal(ServerHttpObservationFilter.java:114)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
	at org.eclipse.jetty.ee10.servlet.FilterHolder.doFilter(FilterHolder.java:205)
	at org.eclipse.jetty.ee10.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1591)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
	at org.eclipse.jetty.ee10.servlet.FilterHolder.doFilter(FilterHolder.java:205)
	at org.eclipse.jetty.ee10.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1591)
	at org.eclipse.jetty.ee10.servlet.ServletHandler$MappedServlet.handle(ServletHandler.java:1552)
	at org.eclipse.jetty.ee10.servlet.ServletChannel.dispatch(ServletChannel.java:819)
	at org.eclipse.jetty.ee10.servlet.ServletChannel.handle(ServletChannel.java:436)
	at org.eclipse.jetty.ee10.servlet.ServletHandler.handle(ServletHandler.java:469)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:575)
	at org.eclipse.jetty.ee10.servlet.SessionHandler.handle(SessionHandler.java:717)
	at org.eclipse.jetty.server.handler.ContextHandler.handle(ContextHandler.java:1060)
	at org.eclipse.jetty.server.Handler$Wrapper.handle(Handler.java:740)
	at org.eclipse.jetty.server.handler.EventsHandler.handle(EventsHandler.java:81)
	at org.eclipse.jetty.server.Server.handle(Server.java:182)
	at org.eclipse.jetty.server.internal.HttpChannelState$HandlerInvoker.run(HttpChannelState.java:662)
	at org.eclipse.jetty.server.internal.HttpConnection.onFillable(HttpConnection.java:418)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:322)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:99)
	at org.eclipse.jetty.io.SelectableChannelEndPoint$1.run(SelectableChannelEndPoint.java:53)
	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.runTask(AdaptiveExecutionStrategy.java:480)
	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.consumeTask(AdaptiveExecutionStrategy.java:443)
	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.tryProduce(AdaptiveExecutionStrategy.java:293)
	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.run(AdaptiveExecutionStrategy.java:201)
	at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:311)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:979)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.doRunJob(QueuedThreadPool.java:1209)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1164)
	at java.base/java.lang.Thread.run(Thread.java:1583)

Additional Information

No response

Browsers Affected

Chrome

No Duplicate of the Issue

  • I have verified that there are no existing issues raised related to my problem.
Copy link

dosubot bot commented Feb 1, 2025

Hey there, @hubdows! I'm here to help you with any bugs, questions, or contributions you may have. Let's squash those bugs together! 🐛

A similar issue was reported in a closed thread, but no solution was found in the comments [1].

For your specific problem, the error message indicates that the qpdf tool encountered warnings during the repair process, which might be causing the PDF to be unavailable for download. Here are a few steps you can try to troubleshoot and potentially resolve the issue:

  1. Check the PDF File: Ensure that the PDF file is not corrupted before attempting the repair. You might want to try repairing a different PDF to see if the issue persists.

  2. Update Docker Image: Make sure you are using the latest version of the Stirling-PDF Docker image. You can update the image by pulling the latest version from the Docker repository.

  3. Inspect Docker Logs: Check the Docker logs for any additional error messages or warnings that might provide more context about the failure.

  4. Adjust Docker Configuration: Review your Docker configuration to ensure that all necessary permissions and environment variables are correctly set.

  5. Test Locally: If possible, try running the repair operation outside of Docker to see if the issue is specific to the Docker environment.

If these steps do not resolve the issue, consider providing more detailed logs or error messages to help further diagnose the problem.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@dosubot dosubot bot added the Back End Issues related to back-end development label Feb 1, 2025
@hubdows
Copy link
Author

hubdows commented Feb 1, 2025

Just to add some context about the PDF file. It was a magazine file that was 335mb, it opened fine in Adobe and Foxit Reader. I ran it through StirlingPDF Repair to see if what it would do when I encountered the error. This was the first command I tried in Stirling, so I'm hoping it's not a Docker issue. I will check other commands to see if they work.

I also ran the same file through ILovePDF desktop app and it automatically repaired/compressed the file to 107mb without error.

My docker image is the latest version just downloaded from Docker Hub, running on a Synology NAS using their Container manager. No log errors on the Synology NAS.

@Abdurrahman-shaikh
Copy link
Contributor

Hi @hubdows and maintainers,

I’ve reviewed the issue and believe I can help resolve it. The problem appears to be related to how the ProcessExecutor handles qpdf's exit code 3 (warnings), which is currently causing an Internal Server Error despite the PDF being repaired successfully.

I’ve already identified the necessary changes to the ProcessExecutor and RepairController to allow exit code 3 while still serving the repaired PDF. I’d be happy to implement and test these changes.

Could you please assign this issue to me? I’ll submit a pull request once the fix is ready.

Thank you!

@hubdows
Copy link
Author

hubdows commented Feb 3, 2025

I will test as soon as I see an update to the Docker container. Thank you very much for your help!!! I will report back as soon as possible.

@hubdows
Copy link
Author

hubdows commented Feb 4, 2025

Hello, I just want to let you know that the Alpha build REPAIR feature worked correctly. After completing the repair, the repaired file was automatically downloaded. No errors in the logs. Thank YOU!

@hubdows hubdows closed this as completed Feb 4, 2025
Frooodle added a commit that referenced this issue Feb 4, 2025
)

# Description of Changes

Please provide a summary of the changes, including:

- **What was changed**:
- Modified the `ProcessExecutor` class to accept exit code `3` from
**qpdf** as a success with warnings.
- Added a check to ensure that only **qpdf**’s exit code `3` is treated
as a warning.
- Added a warning log for **qpdf** exit code `3` to provide better
visibility into the repair process.

- **Why the change was made**:
- The repair process was failing when **qpdf** returned exit code `3`,
even though the operation succeeded with warnings. This caused
unnecessary errors for users.
- The changes ensure that PDFs with minor structural issues (e.g.,
mismatched object counts) are still repaired successfully, while logging
warnings for transparency.
- Added a check to ensure that only **qpdf**’s exit code `3` is treated
as a warning, preventing potential issues with other tools that might
use exit code `3` for actual errors.

Closes #2842

---

## Checklist

### General

- [x] I have read the [Contribution
Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md)
- [x] I have read the [Stirling-PDF Developer
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md)
(if applicable)
- [x] I have performed a self-review of my own code
- [x] My changes generate no new warnings

### Testing (if applicable)

- [x] I have tested my changes locally.
- Verified that exit code `3` is only treated as a warning for **qpdf**
and not for other tools.

---

### Additional Notes
- The changes align with **qpdf**'s behavior, where exit code `3`
indicates a successful operation with warnings.
- Added a check to ensure that only **qpdf**’s exit code `3` is treated
as a warning, preventing potential issues with other tools.

Co-authored-by: Anthony Stirling <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Back End Issues related to back-end development
Projects
None yet
2 participants