iflytek/astron-agent · error · Exception

file is null

Error message

file %s is null

What it means

After successfully opening and reading the file, __call__ checks the read content is non-empty. If the file exists but contains zero bytes (or only whitespace yields a falsy string), an Exception 'file %s is null' is raised.

Solutions

  1. Open the file and paste/restore the correct JSON schema content
  2. Restore the file from version control (git checkout -- <file>) or re-download it
  3. Delete the empty file if it is not needed, then ensure it is regenerated at build time

Example fix

// before (file exists but is empty)
$ touch user_schema.json
// after
$ echo '{"type":"object"}' > user_schema.json
Defensive patterns

Strategy: validation

Validate before calling

import os
p = os.path.join(schemas_dir, "my_schema.json")
if os.path.getsize(p) == 0:
    raise ValueError(f"schema file is empty: {p}")

Try / catch

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

Prevention

When it happens

Trigger: Calling the reader with a .json file that exists in the directory but is empty (0 bytes), e.g. a placeholder committed to the repo or a file truncated by a failed write.

Common situations: Empty placeholder schema files committed accidentally; interrupted writes/truncated files from bad deploys; files emptied by a build step; creating the file with touch and forgetting to fill it.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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

Appendix: source

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

        :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": {
    #             "domain": "generalv3.5",
    #             "temperature": 0.1,
    #             "max_tokens": 1024,
    #             "top_k": 3,
    #             "question_type": "not_knowledge",

View on GitHub (pinned to 5e758547a8)