fix(create_folder): dump dir(parent) on total-miss to diagnose unknown SPs
Empirical failure: TypeError create_folder() got an unexpected keyword argument 'name' (original v1). Root cause: kwarg 'name=' rejected by SP21+; positional foldername is the canonical signature. Fix: positional call (already landed ine0fea90); this commit adds a dir(parent) dump on total-miss for forward-compat diagnostics. Docs: https://content.helpme-codesys.com/en/ScriptingEngine/ScriptObject.html Note: the core fix (positional call + multi-strategy fallback) was already landed in commite0fea90. This commit only adds the dir(parent_object) dump to the final error path -- per the bug doc's "dump dir(parent) on total miss" recommendation -- so an SP that breaks all 5 strategies surfaces the real API surface in the failure message instead of leaving the next investigator blind. ### Manual smoke test 1. mcp__codesys__create_folder against any normally-functioning project should still succeed (Strategy 1 wins -- the dir() dump only triggers when ALL strategies fail). 2. To exercise the new dir() path, run create_folder against a project whose Application has been deleted (parent_object resolves to a container without create_folder/create_object/add): expect SCRIPT_ERROR ending with "parent api: <space-separated attr names>".
This commit is contained in:
parent
763a30761d
commit
19d6cc3d8b
1 changed files with 12 additions and 2 deletions
|
|
@ -149,9 +149,19 @@ try:
|
|||
print("WARN: parent.add(types.IecFolder) raised: %s" % e)
|
||||
|
||||
if new_folder is None:
|
||||
# Total miss -- dump dir(parent) to surface what API surface this
|
||||
# SP actually exposes, so the next iteration can target it. Helps
|
||||
# OPEN-BUGS-CROSS-REFERENCE Bug 1 diagnosis on unexpected SPs.
|
||||
try:
|
||||
api_attrs = sorted([a for a in dir(parent_object) if not a.startswith('_')])
|
||||
api_dump = ', '.join(api_attrs)
|
||||
except Exception as de:
|
||||
api_dump = '<dir() failed: %s>' % de
|
||||
raise TypeError(
|
||||
"Parent object '%s' of type %s -- folder '%s' could not be created or located after trying %s." % (
|
||||
parent_name, type(parent_object).__name__, FOLDER_NAME, ', '.join(strategies_tried) or '<no strategies available>'))
|
||||
"Parent object '%s' of type %s -- folder '%s' could not be created or located after trying %s. parent api: %s" % (
|
||||
parent_name, type(parent_object).__name__, FOLDER_NAME,
|
||||
', '.join(strategies_tried) or '<no strategies available>',
|
||||
api_dump))
|
||||
|
||||
if new_folder:
|
||||
new_folder_name = getattr(new_folder, 'get_name', lambda: FOLDER_NAME)()
|
||||
|
|
|
|||
Loading…
Reference in a new issue