@@ -285,13 +285,18 @@ export async function readArgumentSource(
285285 * ids, or the value itself. See {@link FlagSpec.fileReferences} for why neither reading can
286286 * misread a single id or path.
287287 */
288- function fileReferenceEntries ( value : string ) : string [ ] {
288+ function fileReferenceEntries ( value : string , flagName : string ) : string [ ] {
289289 const entries = value . startsWith ( '[' )
290290 ? jsonStringArray ( value )
291291 : value . includes ( ',' ) && ! value . includes ( '/' )
292292 ? value . split ( ',' )
293293 : undefined
294- return entries ? entries . map ( ( entry ) => entry . trim ( ) ) . filter ( Boolean ) : [ value ]
294+ if ( ! entries ) return [ value ]
295+ const trimmed = entries . map ( ( entry ) => entry . trim ( ) )
296+ if ( trimmed . some ( ( entry ) => ! entry ) ) {
297+ throw new SimApiError ( `--${ flagName } values cannot be empty: ${ value } ` , 0 )
298+ }
299+ return trimmed
295300}
296301
297302function jsonStringArray ( value : string ) : string [ ] | undefined {
@@ -473,9 +478,11 @@ export async function coerce(
473478 */
474479 if ( flag . list ) {
475480 const listed = await readListValues ( raw , flagName , flag . manifest === true )
476- const values = ( flag . fileReferences ? listed . flatMap ( fileReferenceEntries ) : listed ) . map (
477- ( value ) => ( flag . folderPath ? encodeFolderPath ( value ) : value )
478- )
481+ const values = (
482+ flag . fileReferences
483+ ? listed . flatMap ( ( value ) => fileReferenceEntries ( value , flagName ) )
484+ : listed
485+ ) . map ( ( value ) => ( flag . folderPath ? encodeFolderPath ( value ) : value ) )
479486 // Encoding first is also what keeps the comma-joined form unambiguous: a
480487 // folder name containing a comma leaves here as `%2C`, so the route's split
481488 // cannot cut one path in half.
0 commit comments