Skip to content

Conversation

mathause
Copy link
Contributor

overrides, exclude and ignored_validations were not optional, and setting

exclude: []

did not work. Is there another way?

@mathause
Copy link
Contributor Author

Thanks for all your work updating the action by the way! Really cool & I like the three categories!

@keewis
Copy link
Member

keewis commented Sep 10, 2025

This works for me on main:

channels:
  - conda-forge
platforms:
  - noarch
  - linux-64
policy:
  # all packages in months
  packages:
    python: 30
    numpy: 18
  default: 12
  # overrides for the policy
  overrides: {}
  # these packages are completely ignored
  exclude: []
  # these packages don't fail the CI, but will be printed in the report
  ignored_violations: []

I do think that being explicit (i.e. requiring the keys) is a good thing, although I guess the schema doesn't encode that intention.

@keewis
Copy link
Member

keewis commented Sep 10, 2025

do you have an example / example PR where this failed?

@mathause
Copy link
Contributor Author

I do think that being explicit (i.e. requiring the keys) is a good thing, although I guess the schema doesn't encode that intention.

Agreed. I got a failure with regionmask/regionmask#627

Failed validating 'type' in schema['properties']['policy']['properties']['overrides']:
    {'additionalProperties': False,
     'patternProperties': {'^[a-z][-a-z_]*': {'format': 'date',
                                              'type': 'string'}},
     'type': 'object'}

On instance['policy']['overrides']:
    []

but I just saw that you used {} for the overrides (while I used []). I'll close this PR and update the docs.

@keewis
Copy link
Member

keewis commented Sep 10, 2025

yeah, overrides is a mapping of package name to version (in JSON types, an "object", which is what the error message is telling you). What could be really useful is catching the validation error and processing it to be more understandable by python users.

(FYI the two composite json types are "object" for a mapping, and "array" for a list)

Also, looks like the schema does encode the intention I mentioned above.

@mathause
Copy link
Contributor Author

Yes the errors from jsonschema are difficult to understand (but rewriting them may amount to re-implementing something similar...).

@mathause mathause closed this Sep 10, 2025
@keewis
Copy link
Member

keewis commented Sep 10, 2025

Since the policy schema is pretty simple, I was thinking about extracting information from the error message: if the error message is

Invalid policy definition: [] is not of type 'object'

Failed validating 'type' in schema['properties']['policy']['properties']['overrides']:
    {'additionalProperties': False,
     'patternProperties': {'^[a-z][-a-z_]*': {'format': 'date',
                                              'type': 'string'}},
     'type': 'object'}

On instance['policy']['overrides']:
    []

Then we have the path of the wrong object in On instance['policy']['overrides'], and the actual and expected types in the first line. This should be sufficient to create a new error message that is friendlier to a python audience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants