Aias00 opened a new issue, #8023:
URL: https://github.com/apache/shenyu/issues/8023

   ### Is there an existing issue for this?
   
   - [x] I have searched the existing issues.
   
   ### Current Behavior
   
   DiagnosticBundleWriter serializes manifest.json before applying the 
archive-wide section-content budget. It then truncates section bytes using 
maxTotalBytes but does not update each section's status, reason or sizeBytes in 
the already-written manifest. For small configured total limits, a section 
reported OK with its original size can be partially written or empty. In 
addition, maxTotalBytes is documented as the maximum total uncompressed bundle 
size, but manifest bytes are not counted against it.
   
   Suggested severity: Medium: downloaded bundles can claim complete successful 
sections whose archived content is truncated or empty.
   
   ### Expected Behavior
   
   Manifest summaries must describe the actual archived sections: final size, 
truncated/skipped state and reason. Enforce the documented total uncompressed 
budget including manifest content, or explicitly define and rename/document a 
sections-only budget. Account for mandatory metadata overhead and impossible 
tiny budgets explicitly rather than silently contradicting the advertised bound.
   
   ### Steps To Reproduce
   
   1. Create two DiagnosticSection.OK values containing small JSON objects (for 
example 80 bytes each), below maxSectionBytes.
   2. Set maxTotalBytes to 100 and write the archive.
   3. Unzip it and compare each section's byte count with manifest.json. The 
second section is cut to the remaining 20 bytes, but its manifest summary still 
says OK and sizeBytes=80.
   4. Sum the uncompressed entry sizes: section bytes may use the whole 
100-byte allowance and manifest.json adds more bytes beyond it.
   
   This is a deterministic proposed writer test based on source order; it was 
not run here.
   
   ### Environment
   
   - ShenYu: master / 2.7.2-SNAPSHOT, commit 
`34f2ed036747936a5e28aea2c94cd9b3cddcce47`.
   - Evidence: source inspection. The reporting environment has no available 
Java runtime, so no Maven/JUnit execution or live reproduction is claimed.
   - These issues concern existing runtime behavior, not the proposed plugin 
DAG implementation.
   
   ### Debug logs
   
   No runtime logs captured; this report is based on the source paths below.
   
   ### Code evidence
   
   - [Manifest emitted before section 
truncation](https://github.com/apache/shenyu/blob/34f2ed036747936a5e28aea2c94cd9b3cddcce47/shenyu-web/src/main/java/org/apache/shenyu/web/diagnostics/DiagnosticBundleWriter.java#L69-L85)
   - [Summary reflects original section status and 
size](https://github.com/apache/shenyu/blob/34f2ed036747936a5e28aea2c94cd9b3cddcce47/shenyu-web/src/main/java/org/apache/shenyu/web/diagnostics/DiagnosticManifest.java)
   - [Explicit TRUNCATED status is already 
available](https://github.com/apache/shenyu/blob/34f2ed036747936a5e28aea2c94cd9b3cddcce47/shenyu-web/src/main/java/org/apache/shenyu/web/diagnostics/DiagnosticSection.java)
   - [maxTotalBytes documented as total uncompressed bundle 
size](https://github.com/apache/shenyu/blob/34f2ed036747936a5e28aea2c94cd9b3cddcce47/shenyu-web/src/main/java/org/apache/shenyu/web/diagnostics/DiagnosticProperties.java)
   
   ### Suggested fix direction
   
   Precompute final section allocation and corresponding summaries before 
serializing the manifest. Include manifest-size accounting with a bounded 
allocation strategy, or clearly change the configuration contract to 
sections-only after review. Preserve deterministic entry names and ensure 
consumers can identify partial content without trying to parse it as complete 
JSON.
   
   ### Acceptance criteria
   
   - Archived byte lengths match manifest sizeBytes after total-budget 
truncation.
   - Cut/empty sections are explicitly TRUNCATED or SKIPPED with a useful 
reason, never falsely OK.
   - Test total-budget exhaustion across multiple sections and multibyte 
content.
   - Assert the documented uncompressed-size bound and defined behavior for 
budgets smaller than mandatory manifest metadata.
   - Section-specific truncation and ordinary complete bundles remain correct.
   
   ### Related work
   
   Diagnostic bundle feature #7936 / #7961. Separate from section collection 
timeout enforcement.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to