autopkg / jaharmi-recipes

Recipes for the Mac OS X system administration tool, Autopkg
13 stars 18 forks source link

Fix substitution error by removing unused version detection #56

Closed octomike closed 2 years ago

octomike commented 2 years ago

For quite a while now we see a daily error message in our autopkg report:

    Use of undefined key in variable substitution: 'version'

Today I found it it's the Signal download recipe causing it. Specifically, by naming the output variable %version% instead of just version, an internal autopkg function gets confused:

-> item = RE_KEYREF.sub(getdata, item)
(Pdb) n
> /Library/AutoPkg/autopkglib/__init__.py(438)do_variable_substitution()
-> except KeyError as err:
(Pdb) n
> /Library/AutoPkg/autopkglib/__init__.py(439)do_variable_substitution()
-> log_err(f"Use of undefined key in variable substitution: {err}")
(Pdb) err
KeyError('version')
(Pdb) item
'%version%'
(Pdb) RE_KEYREF
re.compile('%(?P<key>[a-zA-Z_][a-zA-Z_0-9]*)%')
(Pdb) RE_KEYREF.sub(getdata, item)
*** KeyError: 'version'
(Pdb) n
Use of undefined key in variable substitution: 'version'
> /Library/AutoPkg/autopkglib/__init__.py(453)do_variable_substitution()

First I fixed it by renaming the output variable, but since I couldn't find an actual use of the version output anywhere, I removed the processor completely.