the-13th-letter / derivepassphrase

an almost-faithful Python reimplementation of James Coglan's vault, a deterministic password manager/generator
MIT License
0 stars 0 forks source link

`derivepassphrase --config` requires configuration directory to exist #6

Closed the-13th-letter closed 2 months ago

the-13th-letter commented 2 months ago
$ derivepassphrase -k --config
Suitable SSH keys:       
[1] ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBjuC9...
[2] ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIG/RzZ...
Your selection? (1-2, leave empty to abort): 1    
Traceback (most recent call last):                                                                        
  File ".../derivepassphrase", line 8, in <module>
    sys.exit(derivepassphrase())      
             ^^^^^^^^^^^^^^^^^^                                                                           
  File ".../click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)               
           ^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                     
  File ".../click/core.py", line 1078, in main
    rv = self.invoke(ctx)      
         ^^^^^^^^^^^^^^^^                                                                                 
  File ".../click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../derivepassphrase/cli.py", line 1030, in derivepassphrase
    _save_config(configuration)
  File ".../derivepassphrase/cli.py", line 119, in _save_config
    with open(filename, 'w', encoding='UTF-8') as fileobj:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '.../.derivepassphrase/settings.json'

(Also demonstrated in #5.)

I believe it makes sense to handle FileNotFoundError here, but probably no other OSError variant, since these are not generally encountered in normal circumstances. I think.