ssssssss-team/spider-flow · error · ExpressionError

Expected '}', but got

Error message

Expected '}', but got '<token text>'

What it means

Parser syntax error raised in parseMapLiteral: after a key:value pair, if the next token is not '}' the parser expects a comma (or the closing curly); stream.expect failed on some other token. The input at fault is a malformed map literal such as {a: 1 b: 2} (missing comma between pairs) or an unterminated {a: 1. Reached via parseAccessOrCallOrLiteral whenever an expression begins with '{'.

Solutions

  1. Separate map entries with commas: {a: 1, b: 2}.
  2. Add the closing '}' so the map literal is terminated.
  3. Count braces in the expression — an unclosed '{' earlier in the expression can push parsing into this branch.
  4. Test the expression in the expression editor to pinpoint the failing token.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at spider-flow-core/src/main/java/org/spiderflow/core/expression/parsing/Parser.java:177 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of ssssssss-team/spider-flow@c799cca99c (2026-09-08). Data as JSON: /api/errors/9c31bfbc63127dc9. Report an issue: GitHub.

Appendix: source

Thrown at spider-flow-core/src/main/java/org/spiderflow/core/expression/parsing/Parser.java:177

	}

	private static Expression parseMapLiteral (TokenStream stream) {
		Span openCurly = stream.expect(TokenType.LeftCurly).getSpan();

		List<Token> keys = new ArrayList<>();
		List<Expression> values = new ArrayList<>();
		while (stream.hasMore() && !stream.match("}", false)) {
			if(stream.match(TokenType.StringLiteral, false)){
				keys.add(stream.expect(TokenType.StringLiteral));
			}else{
				keys.add(stream.expect(TokenType.Identifier));
			}
			
			stream.expect(":");
			values.add(parseExpression(stream));
			if (!stream.match("}", false)) stream.expect(TokenType.Comma);
		}
		Span closeCurly = stream.expect("}").getSpan();
		return new MapLiteral(new Span(openCurly, closeCurly), keys, values);
	}

	private static Expression parseListLiteral (TokenStream stream) {
		Span openBracket = stream.expect(TokenType.LeftBracket).getSpan();

		List<Expression> values = new ArrayList<>();
		while (stream.hasMore() && !stream.match(TokenType.RightBracket, false)) {
			values.add(parseExpression(stream));
			if (!stream.match(TokenType.RightBracket, false)) stream.expect(TokenType.Comma);
		}

		Span closeBracket = stream.expect(TokenType.RightBracket).getSpan();
		return new ListLiteral(new Span(openBracket, closeBracket), values);
	}

	private static Expression parseAccessOrCall (TokenStream stream,TokenType tokenType) {
		//Span identifier = stream.expect(TokenType.Identifier);

View on GitHub (pinned to c799cca99c)