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

home interface plug attribute "read: all" triggers ValidationError #5171

Open
florcabral opened this issue Dec 7, 2024 · 0 comments
Open

Comments

@florcabral
Copy link

florcabral commented Dec 7, 2024

Bug Description

Snapcraft fails to compile a snap when trying to use the home interface plug attribute "read: all".
This ValidationError is thrown: Input should be a valid list [type=list_type, input_value={'home': {'read': ['all']}}, input_type=dict].
The "read: all" feature seems to be introduced by this MR, and is documented in the home interfaces doc. Its description is "read (plug): optional, when set to ‘all’, also allows reading non-hidden files in the home directories of all users as traditional file permissions allow."

If the plug is defined separately, a warning is issued: INFO snap "os-release" has bad plugs or slots: home-all (home plug requires "read" be 'all'), but no access to home is given. Ie,

plugs:
  home-all:
    interface: home
    read: [all]

To Reproduce

Try to build a snap (ie, simple example provided below, taken from snapcraft docs) using the home interface's read attribute:

    plugs: 
      home:
        read: all

Environment

Ubuntu 24.04, LXD

snapcraft.yaml

name: os-release
base: core22
version: '0.2'
summary: Outputs the contents of /etc/os-release
description: Prints the contents of os-release
grade: stable
confinement: strict
apps:
  part-os-release:
    command: bin/os-release.sh
    plugs: 
      home:
        read: [all]
parts:
  part-os-release:
    plugin: dump
    source: .
    organize:
      os-release.sh: bin/

Relevant log output

$ snapcraft 
Traceback (most recent call last):
  File "/snap/snapcraft/13008/bin/snapcraft", line 8, in <module>
    sys.exit(main())
  File "/snap/snapcraft/13008/lib/python3.10/site-packages/snapcraft/application.py", line 485, in main
    return cli.run()
  File "/snap/snapcraft/13008/lib/python3.10/site-packages/snapcraft/cli.py", line 252, in run
    _run_dispatcher(dispatcher, global_args)
  File "/snap/snapcraft/13008/lib/python3.10/site-packages/snapcraft/cli.py", line 225, in _run_dispatcher
    dispatcher.run()
  File "/snap/snapcraft/13008/lib/python3.10/site-packages/craft_cli/dispatcher.py", line 494, in run
    return self._loaded_command.run(self._parsed_command_args)
  File "/snap/snapcraft/13008/lib/python3.10/site-packages/snapcraft/commands/core22/lifecycle.py", line 266, in run
    super().run(parsed_args)
  File "/snap/snapcraft/13008/lib/python3.10/site-packages/snapcraft/commands/core22/lifecycle.py", line 139, in run
    parts_lifecycle.run(self.name, parsed_args)
  File "/snap/snapcraft/13008/lib/python3.10/site-packages/snapcraft/parts/lifecycle.py", line 102, in run
    project = models.Project.unmarshal(yaml_data_for_arch)
  File "/snap/snapcraft/13008/lib/python3.10/site-packages/craft_application/models/base.py", line 61, in unmarshal
    return cls.model_validate(data)
  File "/snap/snapcraft/13008/lib/python3.10/site-packages/pydantic/main.py", line 596, in model_validate
    return cls.__pydantic_validator__.validate_python(
pydantic_core._pydantic_core.ValidationError: 1 validation error for Project
apps.part-os-release.plugs
  Input should be a valid list [type=list_type, input_value={'home': {'read': ['all']}}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.9/v/list_type

Additional context

No response

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

No branches or pull requests

1 participant