@@ -73,6 +73,13 @@ export async function handleLargeSummary(
7373 return summaryContent
7474 }
7575
76+ const summarySize = Math . round (
77+ Buffer . byteLength ( summaryContent , 'utf8' ) / 1024
78+ )
79+ const truncatedSummary = `# Dependency Review Summary
80+
81+ The full dependency review summary was too large to display here (${ summarySize } KB, limit is 1024KB).`
82+
7683 const artifactClient = new DefaultArtifactClient ( )
7784 const artifactName = 'dependency-review-summary'
7885 const files = [ 'summary.md' ]
@@ -87,9 +94,9 @@ export async function handleLargeSummary(
8794 } )
8895
8996 // Return a shorter summary with a link to the artifact
90- const shortSummary = `# Dependency Review Summary
97+ const shortSummary = `${ truncatedSummary }
9198
92- The full dependency review summary is too large to display here. Please download the artifact named "${ artifactName } " to view the complete report.
99+ Please download the artifact named "${ artifactName } " to view the complete report.
93100
94101[View full job summary](${ process . env . GITHUB_SERVER_URL } /${ process . env . GITHUB_REPOSITORY } /actions/runs/${ process . env . GITHUB_RUN_ID } )`
95102
@@ -99,9 +106,14 @@ The full dependency review summary is too large to display here. Please download
99106 return shortSummary
100107 } catch ( error ) {
101108 core . warning (
102- `Failed to handle large summary: ${ error instanceof Error ? error . message : 'Unknown error' } `
109+ `Failed to upload large summary as artifact : ${ error instanceof Error ? error . message : 'Unknown error' } `
103110 )
104- return summaryContent
111+ // Even though artifact upload failed, we must still replace the buffer
112+ // with a truncated summary to prevent core.summary.write() from failing
113+ // with the oversized content (see issue #867)
114+ core . summary . emptyBuffer ( )
115+ core . summary . addRaw ( truncatedSummary )
116+ return truncatedSummary
105117 }
106118}
107119
@@ -268,7 +280,13 @@ async function run(): Promise<void> {
268280 }
269281 }
270282 } finally {
271- await core . summary . write ( )
283+ try {
284+ await core . summary . write ( )
285+ } catch ( error ) {
286+ core . warning (
287+ `Failed to write job summary: ${ error instanceof Error ? error . message : 'Unknown error' } `
288+ )
289+ }
272290 }
273291}
274292
0 commit comments