Skip to content

Commit 9e64790

Browse files
Fix error handler in node download endpoint
1 parent 7608123 commit 9e64790

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

‎aiida_restapi/routers/nodes.py‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,17 +484,17 @@ async def get_node_repo_file_contents(
484484
responses={
485485
404: {'model': errors.NonExistentError, 'description': 'Resource Not Found'},
486486
409: {'model': errors.MultipleObjectsError, 'description': 'Multiple Resources Found'},
487-
422: {'model': errors.InvalidInputError, 'description': 'Validation Error'},
487+
422: {'model': errors.RequestValidationError | errors.InvalidInputError, 'description': 'Validation Error'},
488488
451: {'model': errors.InvalidLicenseError, 'description': 'Invalid License'},
489489
},
490490
)
491491
@with_dbenv()
492492
async def download_node(
493493
uuid: str,
494494
format: t.Annotated[
495-
str,
495+
str | None,
496496
Query(description='Format to download the node in'),
497-
],
497+
] = None,
498498
options: t.Annotated[
499499
str | None,
500500
Query(description='Additional options for archive downloads, provided as a JSON string'),
@@ -506,6 +506,14 @@ async def download_node(
506506
If downloading as an archive, additional options can be provided as a JSON object via the
507507
`options` query parameter.
508508
"""
509+
510+
if format is None:
511+
raise ValidationException(
512+
'Please specify the download format. '
513+
'The available download formats can be '
514+
'queried using the /nodes/download_formats endpoint.',
515+
)
516+
509517
node = orm.load_node(uuid)
510518

511519
if format == 'archive':

0 commit comments

Comments
 (0)