NASA-AMMOS / NASA-AMMOS/AIT-Core
Empty config files can cause errors
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 56
- Forks
- 35
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 3
Description
AIT can fail to gracefully handle empty configuration dictionary files. Adding some checks to make this more robust would be valuable even though it's unlikely most users will run into issues here.
For example, AIT will properly return an empty dictionary if you load the dictionary from a component that doesn't have a configuration file provided. If you edit config.yaml and remove the default command dictionary:
@@ -11,7 +11,7 @@ default:
directory: ../scripts
cmddict:
- filename: cmd.yaml
+ #filename: cmd.yaml
You get nothing when you request a dictionary.
>>> cmd.getDefaultDict()
{}
However, if you pass an empty configuration dictionary the dictionary load will fail:
>>> ait.core.cmd.getDefaultDict()
2024-04-04T13:08:05.331 | INFO | AIT-Core/config/cmd.yaml modified - make a new binary pickle cache file.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "AIT-Core/ait/core/cmd.py", line 508, in getDefaultDict
return util.getDefaultDict(__name__, "cmddict", loader, reload)
File "AIT-Core/ait/core/util.py", line 313, in getDefaultDict
default = ObjectCache(filename, loader).load()
File "AIT-Core/ait/core/util.py", line 83, in load
self._dict = self._loader(self.filename)
File "AIT-Core/ait/core/util.py", line 217, in create
return create.cls(*args, **kwargs)
File "AIT-Core/ait/core/cmd.py", line 410, in __init__
self.load(args[0])
File "AIT-Core/ait/core/cmd.py", line 490, in load
cmds = handle_includes(cmds)
File "AIT-Core/ait/core/cmd.py", line 536, in handle_includes
for d in defns:
TypeError: 'NoneType' object is not iterable
>>>
Contributor guide
No contributing guide indexed for this repository
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 with ait/core/cmd.py, especially load() and handle_includes(), then inspect ait/core/util.py around getDefaultDict() and ObjectCache.load(). Reproduce the failure with an empty configuration dictionary and verify that loading it no longer raises TypeError and returns an empty dictionary, matching the missing-file behavior described in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100