[ 
https://issues.apache.org/jira/browse/TIKA-4793?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18097971#comment-18097971
 ] 

ASF GitHub Bot commented on TIKA-4793:
--------------------------------------

srujana-kuntumalla opened a new pull request, #2962:
URL: https://github.com/apache/tika/pull/2962

   The hard-coded 100 MB ceiling in PipesMessage was not operator-tunable. Add 
PipesConfig.maxIpcPayloadBytes (default 100 MB) and thread it through 
PipesClient, PipesServer, ConnectionHandler, and ServerProtocolIO so the limit 
is applied on every read() call. The write path is unchanged. Includes unit 
tests for default value, JSON loading, and validation.
   
   <!--
     Licensed to the Apache Software Foundation (ASF) under one
     or more contributor license agreements.  See the NOTICE file
     distributed with this work for additional information
     regarding copyright ownership.  The ASF licenses this file
     to you under the Apache License, Version 2.0 (the
     "License"); you may not use this file except in compliance
     with the License.  You may obtain a copy of the License at
   
       http://www.apache.org/licenses/LICENSE-2.0
   
     Unless required by applicable law or agreed to in writing,
     software distributed under the License is distributed on an
     "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     KIND, either express or implied.  See the License for the
     specific language governing permissions and limitations
     under the License.
   -->
   
   Thanks for your contribution to [Apache Tika](https://tika.apache.org/)! 
Your help is appreciated!
   
   Before opening the pull request, please verify that
   * there is an open issue on the [Tika issue 
tracker](https://issues.apache.org/jira/projects/TIKA) which describes the 
problem or the improvement. We cannot accept pull requests without an issue 
because the change wouldn't be listed in the release notes.
   * the issue ID (`TIKA-XXXX`)
     - is referenced in the title of the pull request
     - and placed in front of your commit messages surrounded by square 
brackets (`[TIKA-XXXX] Issue or pull request title`)
   * commits are squashed into a single one (or few commits for larger changes)
   * Tika is successfully built and unit tests pass by running `./mvnw clean 
test`
   * there should be no conflicts when merging the pull request branch into the 
*recent* `main` branch. If there are conflicts, please try to rebase the pull 
request branch on top of a freshly pulled `main` branch
   * if you add new module that downstream users will depend upon add it to 
relevant group in `tika-bom/pom.xml`.
   
   We will be able to faster integrate your pull request if these conditions 
are met. If you have any questions how to fix your problem or about using Tika 
in general, please sign up for the [Tika mailing 
list](http://tika.apache.org/mail-lists.html). Thanks!
   




> Make the Pipes IPC max payload size configurable (currently hard-coded to 100 
> MB)
> ---------------------------------------------------------------------------------
>
>                 Key: TIKA-4793
>                 URL: https://issues.apache.org/jira/browse/TIKA-4793
>             Project: Tika
>          Issue Type: Improvement
>          Components: tika-pipes
>            Reporter: Srinivasarao Daruna
>            Priority: Major
>
> PipesMessage.MAX_PAYLOAD_BYTES (tika-pipes-core) is a compile-time constant 
> set to 100 MB:
> // 
> tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/protocol/PipesMessage.java:44
> public static final int MAX_PAYLOAD_BYTES = 100 * 1024 * 1024;
> This cap is enforced on the read side of every IPC message in the 
> PipesClient↔PipesServer socket protocol. It does not limit the file size 
> being parsed (files are fetched server-side by a Fetcher); it limits the size 
> of the serialized JSON payload — most critically the PipesResult (parsed 
> metadata + extracted text) returned in FINISHED messages.
> Problems with the current implementation:
> 1. Hard-coded, not configurable. Users with very large documents that produce 
> large parse results (and no MetadataWriteLimiterFactory configured) have no 
> way to raise the cap short of forking the code. There is no corresponding 
> field in PipesConfig.
> 2. No write-side guard. PipesMessage.write() applies no limit before writing. 
> When the server serializes a PipesResult exceeding 100 MB and sends it, the 
> client's PipesMessage.read() throws IOException("Payload length X exceeds 
> maximum of 104857600 bytes"). This is caught by the catch-all Exception block 
> in PipesClient.waitForServer() and surfaced to the caller as 
> UNSPECIFIED_CRASH — a misleading status that provides no indication of the 
> root cause.
> Proposed fix:
> 1. Add maxIpcPayloadBytes to PipesConfig with a default of 100 * 1024 * 1024, 
> loaded from the "pipes" JSON config section (consistent with all other 
> PipesConfig fields).
> 2. Thread the configured value through to both PipesMessage.read() and 
> PipesMessage.write(), replacing the hard-coded constant.
> 3. Add a write-side guard in PipesMessage.write() so oversized results are 
> caught server-side with a descriptive IOException rather than failing 
> silently at the client with UNSPECIFIED_CRASH.
> Example config (proposed):
> {
>   "pipes": {
>     "maxIpcPayloadBytes": 209715200
>   }
> }
> Note: Users hitting this limit should first consider configuring a 
> MetadataWriteLimiterFactory to bound extracted-text size, which is the right 
> long-term solution for very large documents. But the limit should still be 
> configurable for cases where the full content is legitimately needed.
> Affected files:
> - 
> tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/protocol/PipesMessage.java
> - 
> tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/PipesConfig.java
> - 
> tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/PipesClient.java
> - 
> tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/server/PipesServer.java



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to