Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong values accepted for queryables only found in form #1474

Open
anesson-cs opened this issue Jan 15, 2025 · 0 comments
Open

Wrong values accepted for queryables only found in form #1474

anesson-cs opened this issue Jan 15, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@anesson-cs
Copy link
Collaborator

Describe the bug
The value of a queryable is set as its default value even if it is not allowed. We can get this case when a parameter is neither in default parameter of the product type configuration of a provider nor in a potencial constraints file of the provider. We can then find this parameter in a queryables form, and values of this parameter are already taken in eodag in values variable in queryables_by_form().

Code To Reproduce
In ERA5_PL default parameters configuration of cop_cds configuration, remove "ecmwf:download_format": zip. Then, run the following code:

queryables = dag.list_queryables(
    productType="ERA5_PL",
    provider="cop_cds",
    fetch_providers=True,
    **{"ecmwf:download_format": "unarchivedddd"},
)
print(queryables["ecmwf:download_format"])

Output
typing.Annotated[typing.Literal['unarchived', 'zip'], FieldInfo(annotation=NoneType, required=False, default='unarchivedddd', title='Download format', description="If you select 'Zip' the files will always be zipped into a single file. <br><br> If you select 'Unarchived' then the files will be returned unzipped if there is only one file, and zipped if there are multiple files. <br><br> Please note that in some circumstances the conversion from GRIB to NetCDF can result in multiple files.")]

Environment:

  • Python version: 3.12.3
  • EODAG version: 3.0.0b4.dev121+g7c92c3a7

Additional context
A avenue to go throught this issue is:

# check if default value is allowed
if (default := defaults.get(name)) and default not in values:
    raise ValidationError(
        f"ecmwf:{name}={default} is not allowed. "
        f"Allowed values are {', '.join(values)}."
    )

values variable may be a list containing the values needed (for exemple for year queryable), then a processing of this variable has to be done.

@anesson-cs anesson-cs added the bug Something isn't working label Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant