iflytek/astron-agent · error · Exception
file suffix not .json
Error message
file %s suffix not .json
What it means
ReadJsonSchemas.__call__ reads a JSON schema file from a fixed directory and returns its raw text. Before reading it enforces that the requested file has a '.json' extension; if it does not, a plain Exception is raised. This guards against accidentally passing schema names, IDs, or paths without the extension.
Solutions
- Append the '.json' extension to the file argument before calling the reader
- If the value is an ID/name, resolve it to the actual schema filename ending in .json first
- Strip any directory portion and pass only the bare filename as expected by the reader
Example fix
// before
schema = reader("user_schema")
// after
name = "user_schema" if name.endswith(".json") else name + ".json"
schema = reader("user_schema.json") Defensive patterns
Strategy: validation
Validate before calling
def ensure_json_filename(name: str) -> str:
if not name.endswith(".json"):
raise ValueError(f"expected a .json schema filename, got: {name}")
return name Type guard
def is_json_filename(name: object) -> bool:
return isinstance(name, str) and name.endswith(".json") Prevention
- Always pass bare filenames with the .json extension to the reader
- Store schema names in config with the extension included
- Add a unit test asserting the reader raises on non-.json input
When it happens
Trigger: Calling the reader instance with a file argument that does not end with '.json', e.g. reader('my_schema') or reader('schema.txt') or a path with an extension like 'dir/schema.yaml'.
Common situations: Passing a schema identifier from a config or DB instead of the actual filename; forgetting the extension; concatenating a directory that already contains the extension so the name has a doubled or missing suffix.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- The file address is incorrect
- Remote resource URL is malformed
- Remote resource URL must include a hostname
- 无效的年龄组参数: ,有效选项
- Invalid group: . Valid options
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/9a9a42e11f69c076.
Report an issue: GitHub.
Appendix: source
Thrown at core/plugin/link/utils/json_schemas/read_json_schemas.py:168
This class handles the reading and processing of JSON schema files
from a specified directory path.
"""
def __init__(self, dir_path: str):
"""
description: Initialize
:param dir_path:
"""
self.path = dir_path
def __call__(self, file: str) -> str:
"""
description: Synchronous call, read file information
:return:
"""
if not file.endswith(".json"):
raise Exception("file %s suffix not .json" % file)
schema_info = None
if not os.path.exists(os.path.join(self.path, file)):
raise Exception("file %s not exit in dir %s" % (file, self.path))
with open(os.path.join(self.path, file), encoding="utf8") as file_handle:
schema_info = file_handle.read()
if not schema_info:
raise Exception("file %s is null" % file)
return schema_info
if __name__ == "__main__":
import jsonschema
# validate_data = {
# "header": {
# "app_id": "xxxx",
# "uid": "xxxxx"View on GitHub (pinned to 5e758547a8)