mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-03 02:11:48 +00:00
fix(agent): log defensive parse failures in skill_utils
- Add logger.debug with exc_info on YAML/frontmatter and config read paths that previously swallowed exceptions (parse_frontmatter, external dirs, discover_all_skill_config_vars, resolve_skill_config_values). - Align get_disabled_skill_names error logging with exc_info for parity. - Add tests/agent/test_skill_utils.py regression coverage. Made-with: Cursor
This commit is contained in:
parent
37913d9109
commit
4d5408fd16
2 changed files with 136 additions and 6 deletions
|
|
@ -75,7 +75,12 @@ def parse_frontmatter(content: str) -> Tuple[Dict[str, Any], str]:
|
|||
parsed = yaml_load(yaml_content)
|
||||
if isinstance(parsed, dict):
|
||||
frontmatter = parsed
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
logger.debug(
|
||||
"Skill frontmatter YAML parse failed, using line fallback: %s",
|
||||
e,
|
||||
exc_info=True,
|
||||
)
|
||||
# Fallback: simple key:value parsing for malformed YAML
|
||||
for line in yaml_content.strip().split("\n"):
|
||||
if ":" not in line:
|
||||
|
|
@ -136,7 +141,12 @@ def get_disabled_skill_names(platform: str | None = None) -> Set[str]:
|
|||
try:
|
||||
parsed = yaml_load(config_path.read_text(encoding="utf-8"))
|
||||
except Exception as e:
|
||||
logger.debug("Could not read skill config %s: %s", config_path, e)
|
||||
logger.debug(
|
||||
"Could not read skill config %s: %s",
|
||||
config_path,
|
||||
e,
|
||||
exc_info=True,
|
||||
)
|
||||
return set()
|
||||
if not isinstance(parsed, dict):
|
||||
return set()
|
||||
|
|
@ -183,7 +193,13 @@ def get_external_skills_dirs() -> List[Path]:
|
|||
return []
|
||||
try:
|
||||
parsed = yaml_load(config_path.read_text(encoding="utf-8"))
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
logger.debug(
|
||||
"Could not read config for external skills dirs %s: %s",
|
||||
config_path,
|
||||
e,
|
||||
exc_info=True,
|
||||
)
|
||||
return []
|
||||
if not isinstance(parsed, dict):
|
||||
return []
|
||||
|
|
@ -337,7 +353,13 @@ def discover_all_skill_config_vars() -> List[Dict[str, Any]]:
|
|||
try:
|
||||
raw = skill_file.read_text(encoding="utf-8")
|
||||
frontmatter, _ = parse_frontmatter(raw)
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
logger.debug(
|
||||
"Skipping skill file due to read/parse error %s: %s",
|
||||
skill_file,
|
||||
e,
|
||||
exc_info=True,
|
||||
)
|
||||
continue
|
||||
|
||||
skill_name = frontmatter.get("name") or skill_file.parent.name
|
||||
|
|
@ -391,8 +413,13 @@ def resolve_skill_config_values(
|
|||
parsed = yaml_load(config_path.read_text(encoding="utf-8"))
|
||||
if isinstance(parsed, dict):
|
||||
config = parsed
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.debug(
|
||||
"Could not read config for skill config var resolution %s: %s",
|
||||
config_path,
|
||||
e,
|
||||
exc_info=True,
|
||||
)
|
||||
|
||||
resolved: Dict[str, Any] = {}
|
||||
for var in config_vars:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue