jsonschema 3.2.0 traceback with 1.5.16 when including the umask stanza in the hooks section #437

Closed
opened 2021-07-27 16:04:57 +00:00 by mihailim · 3 comments

What I'm trying to do and why

Trying to set umask to 0027 when running before_backup hook scripts.

Steps to reproduce (if a bug)

location:
    source_directories:
        - /various
    exclude_patterns:
        - /root/.cache
    repositories:
        - /path/to/repo.borg
        - ssh://hostspec/remoterepo.borg
storage:
    encryption_passphrase: "redacted"
    checkpoint_interval: 600
    compression: zstd,11
    ssh_command: ssh -i /path/to/pkey
    borg_cache_directory: /path/to/cachedir
    lock_wait: 60
    archive_name_format: '{hostname}-repo-{now}'
retention:
    keep_daily: 730
    keep_weekly: 520
    keep_monthly: 120
    keep_yearly: 10
    prefix: '{hostname}-repo-'
consistency:
    checks:
        - archives
    check_last: 3
    prefix: '{hostname}-repo-'
hooks:
    umask: 0027
    before_backup:
        - /path/to/hookscript

Actual behavior (if a bug)

jsonschema complains with jsonschema.exceptions.UndefinedTypeCheck: Type 'scalar' is unknown to this type checker (see full traceback below). Using the latest stable jsonschema 3.2.0 under Python 3.6.9.

This seems to be caused by borgmatic/config/schema.yaml line 790, where umask is defined as type: scalar which isn't known to jsonschema.

Full traceback:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/jsonschema/_types.py", line 91, in is_type
    fn = self._type_checkers[type]
  File "/usr/lib/python3/dist-packages/pyrsistent/_pmap.py", line 71, in __getitem__
    return PMap._getitem(self._buckets, key)
  File "/usr/lib/python3/dist-packages/pyrsistent/_pmap.py", line 68, in _getitem
    raise KeyError(key)
KeyError: 'scalar'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/jsonschema/validators.py", line 357, in is_type
    return self.TYPE_CHECKER.is_type(instance, type)
  File "/usr/lib/python3/dist-packages/jsonschema/_types.py", line 93, in is_type
    raise UndefinedTypeCheck(type)
jsonschema.exceptions.UndefinedTypeCheck: Type 'scalar' is unknown to this type checker

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/borgmatic", line 11, in <module>
    load_entry_point('borgmatic==1.5.16', 'console_scripts', 'borgmatic')()
  File "/usr/lib/python3/dist-packages/borgmatic/commands/borgmatic.py", line 779, in main
    configs, parse_logs = load_configurations(config_filenames, global_arguments.overrides)
  File "/usr/lib/python3/dist-packages/borgmatic/commands/borgmatic.py", line 579, in load_configurations
    config_filename, validate.schema_filename(), overrides
  File "/usr/lib/python3/dist-packages/borgmatic/config/validate.py", line 114, in parse_configuration
    validation_errors = tuple(validator.iter_errors(config))
  File "/usr/lib/python3/dist-packages/jsonschema/validators.py", line 328, in iter_errors
    for error in errors:
  File "/usr/lib/python3/dist-packages/jsonschema/_validators.py", line 286, in properties
    schema_path=property,
  File "/usr/lib/python3/dist-packages/jsonschema/validators.py", line 344, in descend
    for error in self.iter_errors(instance, schema):
  File "/usr/lib/python3/dist-packages/jsonschema/validators.py", line 328, in iter_errors
    for error in errors:
  File "/usr/lib/python3/dist-packages/jsonschema/_validators.py", line 286, in properties
    schema_path=property,
  File "/usr/lib/python3/dist-packages/jsonschema/validators.py", line 344, in descend
    for error in self.iter_errors(instance, schema):
  File "/usr/lib/python3/dist-packages/jsonschema/validators.py", line 328, in iter_errors
    for error in errors:
  File "/usr/lib/python3/dist-packages/jsonschema/_validators.py", line 272, in type
    if not any(validator.is_type(instance, type) for type in types):
  File "/usr/lib/python3/dist-packages/jsonschema/_validators.py", line 272, in <genexpr>
    if not any(validator.is_type(instance, type) for type in types):
  File "/usr/lib/python3/dist-packages/jsonschema/validators.py", line 359, in is_type
    raise exceptions.UnknownType(type, instance, self.schema)
jsonschema.exceptions.UnknownType: 
Unknown type 'scalar' for validator with schema:

Expected behavior (if a bug)

No crash.

Other notes / implementation ideas

Can be worked around by setting the umask in the hook scripts and removing that stanza from the borgmatic config YAML, of course.

Environment

borgmatic version: 1.5.16
borgmatic installation method: Debian package (self-packaged as before, based on and backported from the upstream sid package)
Borg version: 1.1.15
Python version: 3.6.9
operating system and version: Ubuntu 18.04 LTS

#### What I'm trying to do and why Trying to set `umask` to `0027` when running `before_backup` hook scripts. #### Steps to reproduce (if a bug) location: source_directories: - /various exclude_patterns: - /root/.cache repositories: - /path/to/repo.borg - ssh://hostspec/remoterepo.borg storage: encryption_passphrase: "redacted" checkpoint_interval: 600 compression: zstd,11 ssh_command: ssh -i /path/to/pkey borg_cache_directory: /path/to/cachedir lock_wait: 60 archive_name_format: '{hostname}-repo-{now}' retention: keep_daily: 730 keep_weekly: 520 keep_monthly: 120 keep_yearly: 10 prefix: '{hostname}-repo-' consistency: checks: - archives check_last: 3 prefix: '{hostname}-repo-' hooks: umask: 0027 before_backup: - /path/to/hookscript #### Actual behavior (if a bug) jsonschema complains with `jsonschema.exceptions.UndefinedTypeCheck: Type 'scalar' is unknown to this type checker` (see full traceback below). Using the latest stable jsonschema 3.2.0 under Python 3.6.9. This seems to be caused by borgmatic/config/schema.yaml line 790, where `umask` is defined as `type: scalar` which isn't known to jsonschema. Full traceback: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/jsonschema/_types.py", line 91, in is_type fn = self._type_checkers[type] File "/usr/lib/python3/dist-packages/pyrsistent/_pmap.py", line 71, in __getitem__ return PMap._getitem(self._buckets, key) File "/usr/lib/python3/dist-packages/pyrsistent/_pmap.py", line 68, in _getitem raise KeyError(key) KeyError: 'scalar' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/jsonschema/validators.py", line 357, in is_type return self.TYPE_CHECKER.is_type(instance, type) File "/usr/lib/python3/dist-packages/jsonschema/_types.py", line 93, in is_type raise UndefinedTypeCheck(type) jsonschema.exceptions.UndefinedTypeCheck: Type 'scalar' is unknown to this type checker During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/bin/borgmatic", line 11, in <module> load_entry_point('borgmatic==1.5.16', 'console_scripts', 'borgmatic')() File "/usr/lib/python3/dist-packages/borgmatic/commands/borgmatic.py", line 779, in main configs, parse_logs = load_configurations(config_filenames, global_arguments.overrides) File "/usr/lib/python3/dist-packages/borgmatic/commands/borgmatic.py", line 579, in load_configurations config_filename, validate.schema_filename(), overrides File "/usr/lib/python3/dist-packages/borgmatic/config/validate.py", line 114, in parse_configuration validation_errors = tuple(validator.iter_errors(config)) File "/usr/lib/python3/dist-packages/jsonschema/validators.py", line 328, in iter_errors for error in errors: File "/usr/lib/python3/dist-packages/jsonschema/_validators.py", line 286, in properties schema_path=property, File "/usr/lib/python3/dist-packages/jsonschema/validators.py", line 344, in descend for error in self.iter_errors(instance, schema): File "/usr/lib/python3/dist-packages/jsonschema/validators.py", line 328, in iter_errors for error in errors: File "/usr/lib/python3/dist-packages/jsonschema/_validators.py", line 286, in properties schema_path=property, File "/usr/lib/python3/dist-packages/jsonschema/validators.py", line 344, in descend for error in self.iter_errors(instance, schema): File "/usr/lib/python3/dist-packages/jsonschema/validators.py", line 328, in iter_errors for error in errors: File "/usr/lib/python3/dist-packages/jsonschema/_validators.py", line 272, in type if not any(validator.is_type(instance, type) for type in types): File "/usr/lib/python3/dist-packages/jsonschema/_validators.py", line 272, in <genexpr> if not any(validator.is_type(instance, type) for type in types): File "/usr/lib/python3/dist-packages/jsonschema/validators.py", line 359, in is_type raise exceptions.UnknownType(type, instance, self.schema) jsonschema.exceptions.UnknownType: Unknown type 'scalar' for validator with schema: #### Expected behavior (if a bug) No crash. #### Other notes / implementation ideas Can be worked around by setting the umask in the hook scripts and removing that stanza from the borgmatic config YAML, of course. #### Environment **borgmatic version:** 1.5.16 **borgmatic installation method:** Debian package (self-packaged as before, based on and backported from the upstream sid package) **Borg version:** 1.1.15 **Python version:** 3.6.9 **operating system and version:** Ubuntu 18.04 LTS
Owner

Ugh, good catch! Thank you so much for taking the time to file this.

Ugh, good catch! Thank you so much for taking the time to file this.
witten added the
bug
label 2021-07-27 16:28:08 +00:00
Owner

Fix is in master. You can use it to modify your schema manually if you need an immediate fix. About to do a bug fix release for this as well.

Fix is in master. You can use it to modify your schema manually if you need an immediate fix. About to do a bug fix release for this as well.
Owner

Okay, the fix is released in borgmatic 1.5.17. Thanks again!

Okay, the fix is released in borgmatic 1.5.17. Thanks again!
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#437
No description provided.