Skip to content

Commit 4d613fb

Browse files
rdmarshclaude
andcommitted
v1.8.6: unknown field warning, tighter warning messages, appliesTo pattern
- Warn when -f includes a field not returned by the API; correct singular/plural (unknown field / unknown fields) - Suppress follow-on warnings when all fields are invalid and output() already reported an error - Reword size limit warning to "results truncated by size limit" - Reword unknown total warning to "total unknown, results may be truncated" - Add appliesTo filter and active/inactive check patterns to elm-notes.yaml Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 52fa261 commit 4d613fb

5 files changed

Lines changed: 61 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
66

77
## [Unreleased]
88

9+
## [1.8.6] - 2026-05-21
10+
11+
### Added
12+
- Unknown field warning: when `-f` includes a field not returned by the API, a
13+
warning is printed listing the missing field(s) with correct singular/plural
14+
(`Warning: unknown field: foo` / `Warning: unknown fields: foo, bar`).
15+
- Both follow-on warnings suppressed when all requested fields are invalid and
16+
`output()` has already reported `Error: no valid fields selected`.
17+
918
### Changed
1019
- `ai.md`: added principle #10 — prefer simple, readable code over clever solutions; added matching bullet to "Working with code" behaviour rules.
1120
- `ai.md`: verification section now explicitly names hallucinated library APIs as the failure mode that "run the code" is defending against.
@@ -14,6 +23,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
1423
- `ai.md`: principle 6 (isolated sessions) now names the mechanism — context window degradation — not just the symptoms.
1524
- `ai.md`: "Working with code" now includes a note on copyright/IP — avoid reproducing verbatim patterns from known licensed sources.
1625
- `ai.md`: "Scope of authorisation" now instructs the AI to explain suggested shell commands before the user runs them and flag anything destructive.
26+
- Size limit warning reworded to `Warning: results truncated by size limit`.
27+
- Unknown total warning reworded to `Warning: total unknown, results may be truncated`.
28+
- `elm-notes.yaml`: added `appliesTo` filter and active/inactive check patterns to
29+
`DatasourceList`; noted that `/* */` comments are common disable mechanism and
30+
Python is more reliable than jq for stripping them.
1731

1832
## [1.8.5] - 2026-05-18
1933

SECURITY.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ hit a bug or vulnerability, pull the latest source and recompile.
77

88
| Version | Supported |
99
| ------- | ------------------ |
10+
| 1.8.6 | :white_check_mark: |
1011
| 1.8.5 | :white_check_mark: |
11-
| 1.8.4 | :white_check_mark: |
12-
| < 1.8.4 | :x: |
12+
| < 1.8.5 | :x: |
1313

1414
## Security History
1515

_jnja/engine.py.j2

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def engine(elm, **kwargs):
206206
logging.debug('total is a flag, showing total instead')
207207
if obj['total'] < 0:
208208
# LM returns -(n_returned + 1) when it cannot compute an exact total
209-
click.secho('Warning: total records unknown, there is data you are not seeing.',
209+
click.secho('Warning: total unknown, results may be truncated',
210210
fg='yellow', err=True)
211211
click.echo('>{}'.format(abs(obj['total']) - 1))
212212
else:
@@ -217,11 +217,22 @@ def engine(elm, **kwargs):
217217
else:
218218
output(obj['items'], elm.command, elm.filename, elm.format, elm.noheader, elm.index, elm.head, elm.foot)
219219

220-
#give a warning if there are more records not shown
221-
if 'size' in flags and (obj['total'] > flags['size'] or obj['total'] < 0):
222-
click.secho('Warning: size limit is less than total records,'
223-
' there is data you are not seeing.',
224-
fg='yellow', err=True)
220+
#if output() found no valid fields it already reported an error — suppress follow-on warnings
221+
returned = set(obj['items'][0].keys()) if obj['items'] else set()
222+
223+
if returned:
224+
#give a warning if there are more records not shown
225+
if 'size' in flags and (obj['total'] > flags['size'] or obj['total'] < 0):
226+
click.secho('Warning: results truncated by size limit',
227+
fg='yellow', err=True)
228+
229+
#warn if any requested fields were not returned by the API
230+
if 'fields' in flags:
231+
missing = {f.strip() for f in flags['fields'].split(',')} - returned
232+
if missing:
233+
label = 'field' if len(missing) == 1 else 'fields'
234+
click.secho('Warning: unknown {}: {}'.format(label, ', '.join(sorted(missing))),
235+
fg='yellow', err=True)
225236

226237
def output(items, command, filename='-', format='json', noheader=False, index=False, head='', foot=''):
227238
import pandas as pd

_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# _version.py
2-
__version__ = '1.8.5'
2+
__version__ = '1.8.6'

elm-notes.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,33 @@ DatasourceList:
312312
filter_patterns:
313313
- "name:NTPv4 # exact name match — use : not ~ when you know the exact name;
314314
avoids retrieving all 1000+ datasources"
315+
patterns:
316+
appliesTo_filter: |
317+
# Find all datasources referencing a property in their AppliesTo expression
318+
elm DatasourceList -F 'appliesTo~purestorage.apitoken.pass' -s0 -f name,displayName,appliesTo
319+
appliesTo_active_check: |
320+
# Distinguish active from disabled AppliesTo expressions.
321+
#
322+
# Two common disable patterns in LM:
323+
# 1. /* purestorage.apitoken.pass */ — C-style comment wrapping
324+
# 2. false() && purestorage.apitoken.pass — short-circuit AND
325+
#
326+
# jq can strip /* */ comments with gsub but cannot reliably detect all
327+
# false() && (...) patterns. /* */ is widely used in this portal, so use
328+
# Python for reliable active-vs-inactive checking:
329+
elm DatasourceList -F 'appliesTo~purestorage.apitoken.pass' -s0 -f name,displayName,appliesTo | \
330+
python3 -c "
331+
import sys, re, json
332+
data = json.load(sys.stdin)
333+
for ds in data['DatasourceList']:
334+
expr = ds.get('appliesTo', '')
335+
stripped = re.sub(r'/\*.*?\*/', '', expr, flags=re.DOTALL)
336+
if re.search(r'purestorage\.apitoken\.pass', stripped):
337+
print(f\"{ds['name']}\t{ds['displayName']}\t{expr}\")
338+
" | column -t -s$'\t'
339+
#
340+
# Replace 'purestorage.apitoken.pass' with any property or expression fragment.
341+
# Note: false() && (...) still slips through — eyeball those rows.
315342
316343
AssociatedDeviceListByDataSourceId:
317344
path: /setting/datasources/{id}/devices

0 commit comments

Comments
 (0)