cayleygraph/cayley · info

ErrParseMore

ErrParseMore

Error message

query: more input required

What it means

ErrParseMore is a sentinel error returned by REPL-oriented parsers (query.Repl, query.Parse) when the submitted input is a syntactically incomplete prefix of a valid query — e.g. unbalanced opening parentheses. It is not a failure; it signals that the caller should collect more input and re-submit the accumulated buffer.

Source

Thrown at query/session.go:27

// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Package query defines the graph session interface general to all query languages.
package query

import (
	"context"
	"errors"
	"fmt"
	"io"

	"github.com/cayleygraph/cayley/graph"
)

var ErrParseMore = errors.New("query: more input required")

type ErrUnsupportedCollation struct {
	Collation Collation
}

func (e *ErrUnsupportedCollation) Error() string {
	return fmt.Sprintf("unsupported collation: %v", e.Collation)
}

// Iterator for query results.
type Iterator interface {
	// Next advances the iterator to the next value, which will then be available through
	// the Result method. It returns false if no further advancement is possible, or if an
	// error was encountered during iteration.  Err should be consulted to distinguish
	// between the two cases.
	Next(ctx context.Context) bool
	// Results returns the current result. The type depends on the collation mode of the query.
	Result() interface{}

View on GitHub (pinned to 81dcd7d73e)

Solutions

  1. Continue reading input (REPLs at internal/repl/repl.go do exactly this) and concatenate until the parse succeeds.
  2. Check parentheses/quote balance in the input before sending.
  3. If input is supposed to be complete, inspect for a stray unclosed '(' or an unterminated string literal.

Example fix

// before
err := session.Execute(ctx, "(g.V")
// after
buf := "(g.V"
if _, err := ses.Parse(ctx, buf); err == query.ErrParseMore {
    buf += readMoreLine() // keep collecting
} else if err != nil {
    return err
}
Defensive patterns

Strategy: type-guard

Validate before calling

if strings.Count(input, "(") != strings.Count(input, ")") {
    // input incomplete; keep buffering
}

Type guard

func isParseMore(err error) bool { return err == query.ErrParseMore }

Try / catch

_, err := ses.Parse(ctx, buf)
if errors.Is(err, query.ErrParseMore) {
    buf += nextLine() // collect more input, retry
    continue
} else if err != nil {
    return err
}

Prevention

When it happens

Trigger: Submitting an incomplete s-expression to a session, such as '(g.V' without the closing parenthesis, via session.Parse or in a REPL loop using session.Execute/Run.

Common situations: Multi-line REPL entry where the user is still typing; programmatic line-by-line feeding of queries; trimmed input accidentally dropping a closing paren.

Related errors


AI-assisted analysis of cayleygraph/cayley@81dcd7d73e (2026-09-06). Data as JSON: /api/errors/9060497f9e253edd. Report an issue: GitHub.