Skip to content

Commit

Permalink
fixup! [2/2] [a] Fix: Can't use curl to download a single manifest in…
Browse files Browse the repository at this point in the history
… one invocation (#5918)
  • Loading branch information
dsotirho-ucsc committed Aug 20, 2024
1 parent 99cbd30 commit 465414d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
28 changes: 13 additions & 15 deletions lambdas/service/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,11 +739,10 @@ def validate_json_param(name: str, value: str) -> MutableJSON:
raise BRE(f'The {name!r} parameter is not valid JSON')


def validate_wait(wait: str | None):
if wait is None or wait in ['0', '1']:
pass
else:
raise ValueError
def validate_wait(wait: str):
valid_values = ['0', '1']
if wait not in valid_values:
raise BRE(f'Invalid wait value `{wait}`. Must be one of {valid_values}')


class Mandatory:
Expand Down Expand Up @@ -1320,16 +1319,13 @@ def get_summary():
authentication=request.authentication)


def wait_parameter_spec(*, default: int | None = None) -> JSON:
def wait_parameter_spec(*, default: int) -> JSON:
valid_values = [0, 1]
assert default in (None, *valid_values), default
assert default in valid_values, default
return params.query(
'wait',
schema.optional(
schema.enum(*valid_values)
if default is None else
schema.with_default(default, type_=schema.enum(*valid_values))
),
schema.optional(schema.with_default(default,
type_=schema.enum(*valid_values))),
description=fd('''
If 0, the client is responsible for honoring the waiting period
specified in the `Retry-After` response header. If 1, the server
Expand Down Expand Up @@ -1378,7 +1374,7 @@ def manifest_route(*, fetch: bool, initiate: bool, curl: bool = False):
params.path('token', str, description=fd('''
An opaque string representing the manifest preparation job
''')),
*([] if fetch else [wait_parameter_spec()])
*([] if fetch else [wait_parameter_spec(default=0)])
]
},
method_spec={
Expand Down Expand Up @@ -1697,10 +1693,10 @@ def _file_manifest(fetch: bool, token_or_key: Optional[str] = None):
'`application/x-www-form-urlencoded`')
query_params = request.query_params or {}
_hoist_parameters(query_params, request)
if post:
query_params.setdefault('wait', '1')
if token_or_key is None:
query_params.setdefault('filters', '{}')
if post:
query_params.setdefault('wait', '1')
# We list the `catalog` validator first so that the catalog is validated
# before any other potentially catalog-dependent validators are invoked
validate_params(query_params,
Expand All @@ -1713,6 +1709,8 @@ def _file_manifest(fetch: bool, token_or_key: Optional[str] = None):
default_format = app.metadata_plugin.manifest_formats[0].value
query_params.setdefault('format', default_format)
else:
if not fetch:
query_params.setdefault('wait', '0')
validate_params(query_params,
# If the initial request was a POST to the non-fetch
# endpoint, the 'wait' param will be carried over to
Expand Down
3 changes: 2 additions & 1 deletion lambdas/service/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -11014,7 +11014,8 @@
"enum": [
0,
1
]
],
"default": 0
},
"description": "\nIf 0, the client is responsible for honoring the waiting period\nspecified in the `Retry-After` response header. If 1, the server\nwill delay the response in order to consume as much of that waiting\nperiod as possible. This parameter should only be set to 1 by\nclients who can't honor the `Retry-After` header, preventing them\nfrom quickly exhausting the maximum number of redirects. If the\nserver cannot wait the full amount, any amount of wait time left\nwill still be returned in the `Retry-After` header of the response.\n"
}
Expand Down

0 comments on commit 465414d

Please sign in to comment.