iflytek/astron-agent · error · Exception

file not exit in dir

Error message

file %s not exit in dir %s

What it means

After checking the extension, __call__ verifies the file exists in its configured directory (self.path). If os.path.join(self.path, file) does not exist, a plain Exception is raised reporting the file and directory. Note the typo 'exit' in the message (means 'exist').

Solutions

  1. Verify the file exists at os.path.join(path, filename) and fix the filename typo if any
  2. Check the directory configured for ReadJsonSchemas points at the folder that actually contains the schema files
  3. Ensure schema files are packaged/deployed with the service (not gitignored or excluded from the image)
  4. Use an absolute, verified path when constructing the reader

Example fix

// before
reader = ReadJsonSchemas("schemas")
// after
schemas_dir = os.path.join(os.path.dirname(__file__), "json_schemas")
assert os.path.isdir(schemas_dir)
reader = ReadJsonSchemas(schemas_dir)
Defensive patterns

Strategy: validation

Validate before calling

import os
path = os.path.join(schemas_dir, "my_schema.json")
if not os.path.isfile(path):
    raise FileNotFoundError(f"schema missing: {path}")

Type guard

def schema_exists(dir_path: str, name: str) -> bool:
    return os.path.isfile(os.path.join(dir_path, name))

Try / catch

try:
    schema = reader("my_schema.json")
except Exception as e:
    logger.error("schema file missing or unreadable: %s", e)
    raise

Prevention

When it happens

Trigger: Calling the reader with a .json filename that is not present in the directory passed at construction, e.g. reader = ReadJsonSchemas('/app/schemas'); reader('missing.json') when missing.json is not in /app/schemas.

Common situations: Wrong directory configured for the reader (deployment packaging left the schema dir out); typo in the schema filename; schema added locally but not committed/deployed; running from a working directory where a relative path resolves differently.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12). Data as JSON: /api/errors/764d00422d455084. Report an issue: GitHub.

Appendix: source

Thrown at core/plugin/link/utils/json_schemas/read_json_schemas.py:171

    """

    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"
    #     },
    #     "parameter": {
    #         "chat": {

View on GitHub (pinned to 5e758547a8)