Skip to content

NPE:Cannot invoke "com.fasterxml.jackson.databind.JsonNode.asText()" because the return value of "com.fasterxml.jackson.databind.JsonNode.get(String)" is null #310

Closed
@abinggo

Description

@abinggo

I tried with langchain4j and npx start MCPserver

 List<String> command = List.of(
                "npx",
                "-y",
                "@modelcontextprotocol/server-github"
        );
        Map<String, String> environment = Map.of(
                "GITHUB_PERSONAL_ACCESS_TOKEN

But I find The Json return structure of the 19th tool has an Array type inside.

"comments": {
                "type": "array",
                "items": {
                    "anyOf": [
                        {
                            "type": "object",
                            "properties": {
                                "path": {
                                    "type": "string",
                                    "description": "The relative path to the file being commented on"
                                },
                                "position": {
                                    "type": "number",
                                    "description": "The position in the diff where you want to add a review comment"
                                },
                                "body": {
                                    "type": "string",
                                    "description": "Text of the review comment"
                                }
                            },
                            "required": [
                                "path",
                                "position",
                                "body"
                            ],
                            "additionalProperties": false
                        },
                        {
                            "type": "object",
                            "properties": {
                                "path": {
                                    "type": "string",
                                    "description": "The relative path to the file being commented on"
                                },
                                "line": {
                                    "type": "number",
                                    "description": "The line number in the file where you want to add a review comment"
                                },
                                "body": {
                                    "type": "string",
                                    "description": "Text of the review comment"
                                }
                            },
                            "required": [
                                "path",
                                "line",
                                "body"
                            ],
                            "additionalProperties": false
                        }
                    ]
                },
                "description": "Comments to post as part of the review (specify either position or line, not both)"
            }
        },

But when parsing Json

else if (nodeType.equals("array")) {
            JsonArraySchema.Builder builder = JsonArraySchema.builder();
            if (node.has("description")) {
                builder.description(node.get("description").asText());
            }

            builder.items(jsonNodeToJsonSchemaElement(node.get("items")));
            return builder.build();

The element obtained is an array, and the type and "description" in it cannot be obtained.

String nodeType = node.get("type").asText();JsonNode description = node.get("description");

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions