Repository navigation
Description
Description
Reopening #24274 and #34918, two augeas httpd.lns bugs that were marked as stale and closed, but are still present in salt 3006.3. The straightforward implementation fails with "Invalid formatted command". When adding extra quotes to pacify that error, the state fails with "Error: Augeas.save() failed: No error". Both the additional quoting and removing "lens: httpd.lns" are needed to work around the issues.
Setup
pypi install of salt 3006.3 and python-augeas on Ubuntu 22.04.
Steps to Reproduce the behavior
First, as a reference, here is the augtool command that works fine:
augtool set '/files/etc/apache2/sites-available/default-ssl.conf/IfModule/VirtualHost/directive[. = "SSLCertificateFile"]/arg' /etc/ssl/certs/cert1.pem
Here is the straightforward salt state:
/etc/apache2/sites-available/default-ssl.conf:
augeas.change:
- lens: httpd.lns
- context: /files/etc/apache2/sites-available/default-ssl.conf/IfModule/VirtualHost
- changes:
- set directive[. = "SSLCertificateFile"]/arg /etc/ssl/certs/cert1.pem
When I run this, I get the following error. Excerpt from the -l all log (the full log doesn't seem to have any other useful info):
[TRACE ] Slot processing list value: set directive[. = "SSLCertificateFile"]/arg /etc/ssl/certs/cert1.pem
[ERROR ] set takes (1, 2) args: ['directive[.', '=', 'SSLCertificateFile]/arg', '/etc/ssl/certs/cert1.pem']
[ERROR ] Error: Invalid formatted command, see debug log for details: directive[. = "SSLCertificateFile"]/arg /etc/ssl/certs/cert1.pem
[...]
ID: /etc/apache2/sites-available/default-ssl.conf
Function: augeas.change
Result: False
Comment: Error: Invalid formatted command, see debug log for details: directive[. = "SSLCertificateFile"]/arg /etc/ssl/certs/cert1.pem
Started: 12:14:15.057841
Duration: 8.454 ms
Changes:
Adding quotes to the changes in the state:
/etc/apache2/sites-available/default-ssl.conf:
augeas.change:
- lens: httpd.lns
- context: /files/etc/apache2/sites-available/default-ssl.conf/IfModule/VirtualHost
- changes:
- "set '/files/etc/apache2/sites-available/default-ssl.conf/IfModule/VirtualHost/directive[. = \"SSLCertificateFile\"]/arg' /etc/ssl/certs/cert1.pem"
When I run this, I get:
[TRACE ] Slot processing list value: set '/files/etc/apache2/sites-available/default-ssl.conf/IfModule/VirtualHost/directive[. = "SSLCertificateFile"]/arg' /etc/ssl/certs/cert1.pem
[DEBUG ] set: {'path': '/files/etc/apache2/sites-available/default-ssl.conf/IfModule/VirtualHost/directive[. = "SSLCertificateFile"]/arg', 'value': '/etc/ssl/certs/cert1.pem'}
[ERROR ] Error: Augeas.save() failed: No error
[INFO ] Completed state [/etc/apache2/sites-available/default-ssl.conf] at time 12:32:26.598838 (duration_in_ms=9.537)
[...]
ID: /etc/apache2/sites-available/default-ssl.conf
Function: augeas.change
Result: False
Comment: Error: Augeas.save() failed: No error
Started: 12:32:26.589301
Duration: 9.537 ms
Changes:
Finally, when I remove httpd.lns:
/etc/apache2/sites-available/default-ssl.conf:
augeas.change:
- context: /files/etc/apache2/sites-available/default-ssl.conf/IfModule/VirtualHost
- changes:
- "set '/files/etc/apache2/sites-available/default-ssl.conf/IfModule/VirtualHost/directive[. = \"SSLCertificateFile\"]/arg' /etc/ssl/certs/cert1.pem"
It works:
[TRACE ] Slot processing list value: set '/files/etc/apache2/sites-available/default-ssl.conf/IfModule/VirtualHost/directive[. = "SSLCertificateFile"]/arg' /etc/ssl/certs/cert1.pem
[DEBUG ] set: {'path': '/files/etc/apache2/sites-available/default-ssl.conf/IfModule/VirtualHost/directive[. = "SSLCertificateFile"]/arg', 'value': '/etc/ssl/certs/cert1.pem'}
[INFO ] {'updates': ['set \'/files/etc/apache2/sites-available/default-ssl.conf/IfModule/VirtualHost/directive[. = "SSLCertificateFile"]/arg\' /etc/ssl/certs/cert1.pem']}
[...]
ID: /etc/apache2/sites-available/default-ssl.conf
Function: augeas.change
Result: True
Comment: Changes have been saved
Started: 12:35:33.694015
Duration: 1963.578 ms
Changes:
----------
updates:
- set '/files/etc/apache2/sites-available/default-ssl.conf/IfModule/VirtualHost/directive[. = "SSLCertificateFile"]/arg' /etc/ssl/certs/cert1.pem
Expected behavior
Expected behavior is to run the first example state above without errors. Please fix both bugs -- the need to remove httpd.lns (previously reported as #24274), and the need to add the extra quotes (previously reported as #34918; if the quoting is now intentionally needed, please document this).
Versions Report
salt --versions-report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)Salt Version:
Salt: 3006.3
Python Version:
Python: 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0]
Dependency Versions:
cffi: 1.15.1
cherrypy: Not Installed
dateutil: Not Installed
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 3.1.2
libgit2: Not Installed
looseversion: 1.3.0
M2Crypto: Not Installed
Mako: Not Installed
msgpack: 1.0.6
msgpack-pure: Not Installed
mysql-python: Not Installed
packaging: 23.1
pycparser: 2.21
pycrypto: Not Installed
pycryptodome: 3.19.0
pygit2: Not Installed
python-gnupg: Not Installed
PyYAML: 6.0.1
PyZMQ: 25.1.1
relenv: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.3.4
System Versions:
dist: ubuntu 22.04.3 jammy
locale: utf-8
machine: x86_64
release: 5.15.0-79-generic
system: Linux
version: Ubuntu 22.04.3 jammy
Activity
OrangeDog commentedon Sep 25, 2023
The error is not the same as in the original issue. Now it says:
I will also note that the 22.04 version of
python-augeasis 0.5.0 (from 2014), wheras the latest on PyPi is 1.1.0 . The latter version may work correctly.kartiksubbarao commentedon Sep 25, 2023
Hi @OrangeDog:
OrangeDog commentedon Sep 25, 2023
No, the new one seems to be a failure to interpret the API response.
kartiksubbarao commentedon Sep 25, 2023
Well -- whatever the case may end up being, hopefully someone from the salt team can take an in-depth look and fix the problem :-)
kartiksubbarao commentedon Sep 25, 2023
Tagging some folks from the salt team who responded to the original cases that were unfortunately closed without being resolved. Any chance you can help get this issue some attention? @jfindlay @sagetherage @Ch3LL
1 remaining item
dwoz commentedon Oct 16, 2026
Thanks for the original report. This issue has been open for more than three years without recent activity and carries a severity label below
severity-high. As part of a backlog cleanup, we're closing older low- and medium-severity issues so triage can focus on reports against currently supported releases.Closing isn't a judgement that the problem wasn't real — only that the codebase has moved through several releases since this was filed, and much of the surrounding code has changed.
If you — or anyone else — can still reproduce this on the 3008.x LTS release, please leave a comment with a reproduction and a maintainer will reopen. The original reporter can also reopen directly.
kartiksubbarao commentedon Oct 16, 2026
FYI for anyone who is interested -- I asked ChatGPT to track down the root cause of these issues, here's what it said:
ChatGPT: I investigated the original reports (#24274 and #34918), the 2023 reproduction in this issue, and the implementation of Salt's Augeas integration. There appear to be two distinct problems, and we've now experimentally reproduced the underlying cause of the more obscure one.
1.
Invalid formatted commandThis comes from Salt's use of
shlex_split()to parse Augeas commands.The original command:
gets split into more arguments than the
setoperation expects because of the spaces in the Augeas path predicate.Quoting the entire path fixes that:
This is a command-parsing issue in Salt's wrapper, not a failure of Augeas itself.
2.
Augeas.save() failed: No errorThis problem is more interesting.
In the historical Salt implementation, when both
lensandcontextare specified, Salt disables Augeas's automatic lens loading and explicitly constructs a transform:The critical line is:
Salt passes
contexttoadd_transform()as though it identifies a filesystem file.But the original state specifies:
This is an Augeas tree path, extending inside the Apache configuration file.
After removing
/files, Salt supplies:to
add_transform().Augeas expects a filesystem filename or pattern here, not a path to nodes within a parsed configuration. The actual file ends at
default-ssl.conf.This explains the difference between specifying
lensand omitting it. Without an explicit lens, Augeas can automatically load the actual Apache configuration file. With an explicit lens, Salt instead constructs a transform using the nested context, which does not select the intended file.3. Experimental confirmation
We tested this directly using Python's Augeas bindings in an isolated Ubuntu container.
Three combinations were tested:
Httpd.lnsHttpd.lns/IfModule/VirtualHosthttpd.lnsThis also ruled out lens-name capitalization as the cause.
We then recreated the problematic transform, performed the
setoperation, and calledaug.save()against a temporary copy of the Apache configuration.The result was exactly the exception reported in 2023:
However, inspecting Augeas's internal error tree revealed the underlying failure:
This is the smoking gun.
Augeas was attempting to handle a path extending beneath
default-ssl.confas a filesystem path. Butdefault-ssl.confis a regular file, not a directory, so the operating system returnedNot a directory.The generic Python exception obscured this information because the useful diagnostics were recorded in Augeas's internal error tree.
4. Conclusion
The investigation identified two separate causes:
contextboth to identify a location in the Augeas tree and, when an explicit lens is supplied, to select a filesystem file foradd_transform(). Those are not necessarily interchangeable.The second problem can be avoided by specifying the actual configuration filename as
contextand moving the remaining Augeas tree path into thesetcommand. That is also consistent with Salt's documented expectation thatcontextidentify a file.The experiments directly confirmed the incorrect file selection and reproduced the exact save exception and underlying
Not a directorydiagnostic. They were conducted against current Augeas bindings, not through the original Salt 3006.3 execution module, so they establish the failure mechanism rather than an end-to-end reproduction on that historical release.Finally, Salt 3008.x has removed the
augeas.changestate and its corresponding execution module from core. Consequently, the original SLS cannot be reproduced unchanged on a stock 3008.x installation.Although that limits testing against the current LTS release, the underlying behavior reported in 2015 and again in 2023 now has a concrete, experimentally supported explanation.
dwoz commentedon Oct 22, 2026
Reopening based on the follow-up comment above.
kartiksubbarao commentedon Oct 22, 2026
Thanks @dwoz for reopening the case. I did some additional investigation and testing, and I realized that I've been somewhat chasing my own tail on this issue. It turns out that I didn't fully connect the dots between #24274 and #24275, another issue I reported back in 2015.
In that issue, I discovered that the
contextargument toaugeas.changeneeds to resolve to an actual file, rather than an arbitrary path within the Augeas tree. The salt team updated the documentation accordingly. For some reason, neither I nor the salt team closed #24274 at that time. Maybe I was still focused on the fact that it worked whenlens: httpd.lnswas not specified, so maybe there was a pathway to get it to work even when context didn't resolve to an actual file? That would have been good to see implemented, but I could understand if the developers felt that would introduce more complexity into the code.In any case, I likely memory-holed the resolution to #24275 a few years later when #24274 got marked stale. I kept going back to the original notes and reproducing the same error. Which then carried forward into reviving #24274 as this issue. (#34918-type behavior seems to have been attempted to be addressed by #34640, but was then reverted by #38115, and the documentation updated by #42203).
I also confirmed today with Salt 3006.28 that explicitly specifying
lens: httpd.lnsworks properly whencontextresolves to the actual file. I'm going to close this case now, since the current behavior is documented.