runtimeverification / runtimeverification/kontrol
Unhelpful error message when running Kontrol with invalid `FOUNDRY_PROFILE`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 122
- Forks
- 16
- PR merge metrics
- No merged PRs in 30d
Description
Like Foundry, Kontrol uses the FOUNDRY_PROFILE environment variable to select a profile from foundry.toml. However, if FOUNDRY_PROFILE is set to a profile that doesn't exist (for example, it might have been set for a different project and the user forgot to unset it), Kontrol throws an exception with an unhelpful error message (the example below has FOUNDRY_PROFILE=k):
Traceback (most recent call last):
File "/nix/store/2crjmyp0v36djwj0bpg0q1mjqxj2iq34-python3.10-kontrol-0.1.76/bin/.kontrol-wrapped", line 9, in <module>
sys.exit(main())
File "/nix/store/2crjmyp0v36djwj0bpg0q1mjqxj2iq34-python3.10-kontrol-0.1.76/lib/python3.10/site-packages/kontrol/__main__.py", line 75, in main
execute(**vars(args))
File "/nix/store/2crjmyp0v36djwj0bpg0q1mjqxj2iq34-python3.10-kontrol-0.1.76/lib/python3.10/site-packages/kontrol/__main__.py", line 157, in exec_build
foundry_kompile(
File "/nix/store/2crjmyp0v36djwj0bpg0q1mjqxj2iq34-python3.10-kontrol-0.1.76/lib/python3.10/site-packages/kontrol/kompile.py", line 44, in foundry_kompile
foundry_requires_dir = foundry.kompiled / 'requires'
File "/nix/store/2crjmyp0v36djwj0bpg0q1mjqxj2iq34-python3.10-kontrol-0.1.76/lib/python3.10/site-packages/kontrol/foundry.py", line 84, in kompiled
return self.out / 'kompiled'
File "/nix/store/2crjmyp0v36djwj0bpg0q1mjqxj2iq34-python3.10-kontrol-0.1.76/lib/python3.10/site-packages/kontrol/foundry.py", line 72, in out
return self._root / self.profile.get('out', '')
File "/nix/store/2crjmyp0v36djwj0bpg0q1mjqxj2iq34-python3.10-kontrol-0.1.76/lib/python3.10/site-packages/kontrol/foundry.py", line 68, in profile
return self._toml['profile'][profile_name]
File "/nix/store/74rhjn329qvln8pqgqcrplj3hdp0xs6n-python3.10-tomlkit-0.11.8/lib/python3.10/site-packages/tomlkit/items.py", line 1484, in __getitem__
return cast(Item, self._value[key])
File "/nix/store/74rhjn329qvln8pqgqcrplj3hdp0xs6n-python3.10-tomlkit-0.11.8/lib/python3.10/site-packages/tomlkit/container.py", line 613, in __getitem__
raise NonExistentKey(key)
tomlkit.exceptions.NonExistentKey: 'Key "k" does not exist.'
To fix this, the user needs to run unset FOUNDRY_PROFILE or export FOUNDRY_PROFILE=default to revert back to the default profile, or set it to a different existing profile. But this is not clear from the error message, and if the profile name is not particularly unique, the user might not even realize that this is what is causing the error. This exception should be caught within Kontrol and handled to return a more informative message.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in kontrol/foundry.py at the profile property and trace its use from kontrol/kompile.py and kontrol/main.py. Reproduce the failure with an invalid FOUNDRY_PROFILE; done means Kontrol reports that the selected profile does not exist and explains how to choose or restore an existing profile.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100