File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,6 +51,24 @@ test.beforeEach(() => {
5151 } ) ;
5252} ) ;
5353
54+ test ( "isDiskConfigurationError - true for expected errors" , async ( t ) => {
55+ t . true (
56+ codeql . isDiskConfigurationError ( new Error ( "ENOSPC: Out of disk space" ) ) ,
57+ ) ;
58+ } ) ;
59+
60+ test ( "isDiskConfigurationError - false for other errors" , async ( t ) => {
61+ t . false ( codeql . isDiskConfigurationError ( "Not an Error instance" ) ) ;
62+
63+ const otherMessages = [
64+ "Does not contain an error code we test for" ,
65+ "ENOSP: Not quite the full error code" ,
66+ ] ;
67+ for ( const otherMessage of otherMessages ) {
68+ t . false ( codeql . isDiskConfigurationError ( new Error ( otherMessage ) ) ) ;
69+ }
70+ } ) ;
71+
5472async function installIntoToolcache ( {
5573 apiDetails = SAMPLE_DOTCOM_API_DETAILS ,
5674 cliVersion,
Original file line number Diff line number Diff line change @@ -273,6 +273,21 @@ const GHES_MOST_RECENT_DEPRECATION_DATE = "2026-07-01";
273273/** The CLI verbosity level to use for extraction in debug mode. */
274274const EXTRACTION_DEBUG_MODE_VERBOSITY = "progress++" ;
275275
276+ /**
277+ * Decides whether `e` is a disk-related error outside of our control
278+ * that should be classified as a `ConfigurationError`.
279+ *
280+ * @param e The error to check.
281+ * @returns True if the error should be treated as a `ConfigurationError` or false if not.
282+ */
283+ export function isDiskConfigurationError ( e : unknown ) : boolean {
284+ if ( ! ( e instanceof Error ) ) {
285+ return false ;
286+ }
287+
288+ return e . message . includes ( "ENOSPC" ) ; // out of disk space
289+ }
290+
276291/**
277292 * Set up CodeQL CLI access.
278293 *
@@ -343,8 +358,7 @@ export async function setupCodeQL(
343358 } catch ( rawError ) {
344359 const e = api . wrapApiConfigurationError ( rawError ) ;
345360 const ErrorClass =
346- e instanceof util . ConfigurationError ||
347- ( e instanceof Error && e . message . includes ( "ENOSPC" ) ) // out of disk space
361+ e instanceof util . ConfigurationError || isDiskConfigurationError ( e )
348362 ? util . ConfigurationError
349363 : Error ;
350364
You can’t perform that action at this time.
0 commit comments