FoundationAgents/MetaGPT · warning · NotImplementedError

Not implement:{val}

Error message

Not implement:{val}

What it means

RepoParser._parse_code_block dispatches on the AST node type via a mappings dict; each handler must return a dict (properties), list (tokens), or str (token). If a handler returns any other type, this NotImplementedError is raised with the unexpected value. It marks unhandled AST shapes in the code-block property extractor.

Source

Thrown at metagpt/repo_parser.py:580

                "module": x.module,
                "names": [RepoParser._parse_name(n) for n in x.names],
            },
            any_to_str(ast.If): RepoParser._parse_if,
            any_to_str(ast.AsyncFunctionDef): lambda x: x.name,
            any_to_str(ast.AnnAssign): lambda x: RepoParser._parse_variable(x.target),
        }
        func = mappings.get(any_to_str(node))
        if func:
            code_block = CodeBlockInfo(lineno=node.lineno, end_lineno=node.end_lineno, type_name=any_to_str(node))
            val = func(node)
            if isinstance(val, dict):
                code_block.properties = val
            elif isinstance(val, list):
                code_block.tokens = val
            elif isinstance(val, str):
                code_block.tokens = [val]
            else:
                raise NotImplementedError(f"Not implement:{val}")
            return code_block
        logger.warning(f"Unsupported code block:{node.lineno}, {node.end_lineno}, {any_to_str(node)}")
        return None

    @staticmethod
    def _parse_expr(node) -> List:
        """
        Parses an expression Abstract Syntax Tree (AST) node.

        Args:
            node: The AST node representing an expression.

        Returns:
            List: A list containing the parsed information from the expression node.
        """
        funcs = {
            any_to_str(ast.Constant): lambda x: [any_to_str(x.value), RepoParser._parse_variable(x.value)],
            any_to_str(ast.Call): lambda x: [any_to_str(x.value), RepoParser._parse_variable(x.value.func)],

View on GitHub (pinned to 11cdf466d0)

Solutions

  1. Identify the file being parsed (enable logging around RepoParser calls) and simplify or exclude the offending file
  2. Update or patch the specific handler in mappings to always return dict/list/str (e.g. return {} or [] instead of None)
  3. Skip non-project/vendor directories when invoking the parser

Example fix

// before
def _parse_annassign(node):
    return None  # leads to NotImplementedError

// after
def _parse_annassign(node):
    return []  # or {} — a supported container type
Defensive patterns

Strategy: fallback

Try / catch

try:
    blocks = parser._parse_code_block(node)
except NotImplementedError:
    blocks = None  # parser coverage gap; skip this node rather than abort the scan

Prevention

When it happens

Trigger: Parsing a Python file whose AST contains a node type whose handler (e.g. a docstring/annotation parser) returns None or another unsupported type; typically triggered by calling RepoParser.generate_characters or _parse_code_block over third-party or unusual source files.

Common situations: Running repo parsing / code review flows over codebases with syntax the handlers do not fully cover; new Python syntax features producing AST shapes the handlers return None for; version drift in the handlers' return contracts.

Related errors


AI-assisted analysis of FoundationAgents/MetaGPT@11cdf466d0 (2026-08-14). Data as JSON: /api/errors/da32e463b1af96d1. Report an issue: GitHub.