canonical / snapcraft

Package, distribute, and update any app for Linux and IoT.
https://snapcraft.io
GNU General Public License v3.0
1.18k stars 440 forks source link

Failed to upload snap created with `assumes: - command-chain` #4931

Open chanchiwai-ray opened 1 month ago

chanchiwai-ray commented 1 month ago

Bug Description

When the snap is built with the following section:

assumes:
- command-chain

The snap cannot be uploaded to snap store with the following error:

$ review-tools.snap-review -v tempest_39.0.0_amd64.snap                                                                                                                                                                                                                               
Errors                                                                                                                                                                                                                                                                                    
------                                                                                                                                                                                                                                                                                    
 - lint-snap-v2:snap_schema                                                                                                                                                                                                                                                               
        Error found while validating snap.json::$.assumes: ['command-chain', 'command-chain'] has non-unique elements    

To Reproduce

The bug can be reproduce using the tempest snap as an example: https://github.com/canonical/snap-tempest/blob/main/snap/snapcraft.yaml

I believe other snap with

assumes:
- command-chain

will also fail to upload

Environment

using snapcraft 8.3.1 12136 latest/stable/… canonical✓ classic

snapcraft.yaml

See "To Reproduce" section

Relevant log output

Errors                                                                                                                                                                                                                                                                                    
------                                                                                                                                                                                                                                                                                    
 - lint-snap-v2:snap_schema                                                                                                                                                                                                                                                               
        Error found while validating snap.json::$.assumes: ['command-chain', 'command-chain'] has non-unique elements

Additional context

An inspection of /snap/tempest/current/meta/snap.yaml showed that somehow assumes contains a duplicated command-chain

cat /snap/tempest/current/meta/snap.yaml                                                                                                
name: tempest                                                                                                                                                                                                                                                                             
version: 39.0.0                                                                                                                                                                                                                                                                           
summary: OpenStack Integration Test Suite                                                                                                                                                                                                                                                 
description: |                                                                                                                                                                                                                                                                            
  Tempest is a set of integration tests to be run against a live                                                                             
  OpenStack cluster. Tempest has batteries of tests for OpenStack
  API validation, Scenarios, and other specific tests useful in
  validating an OpenStack deployment.                                                                                                        
license: Apache-2.0                                             
architectures:                      
- amd64                                                                                                                                      
base: core22                                  
assumes:                            
- command-chain                                                                                                                              
- command-chain                                                                                                                                                                                                                                                                           
apps:                    
  tempest:                  
    command: bin/tempest                        
    completer: usr/share/bash-completion/completions/tempest
    plugs:                                                      
    - network-observe                                            
    - network                                                  
    - home                           
    environment:                            
      TESTS: $SNAP_DATA/tempest_test_lists
    command-chain:             
    - bin/tempest-wrapper                                                                                                                    
  discover:    
    command: bin/discover-tempest-config                                                                                                     
    plugs:                                                                                                                                   
    - home                                                                                                                                   
    - network                                                                                                                                
    environment:                                                                                                                             
      SSL_CERT_FILE: $OS_CACERT                                                                                                              
confinement: strict                                                                                                                          
grade: stable                                                                                                                                
environment:                                                                                                                                 
  LD_LIBRARY_PATH: ${SNAP_LIBRARY_PATH}${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}:$SNAP/lib                                                       
  PATH: $SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH  
mr-cal commented 1 month ago

Thanks for the bug report. This is indeed a bug - Snapcraft tries to be helpful and appends command-chain to assumes but it doesn't check if it is already there: https://github.com/canonical/snapcraft/blob/841d735c6777a9ac916dab477c8ba4b998c8bab7/snapcraft/meta/snap_yaml.py#L387-L388

Until this bug is fixed, the easiest workaround is to drop assumes: [command-chain] from your snapcraft.yaml and rely on Snapcraft to add it.

syncronize-issues-to-jira[bot] commented 1 month ago

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/CRAFT-3137.

This message was autogenerated