From 5e89ff4d6b0df4bd54d20d90bee5a16abef6b9bc Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi <1591639+s1na@users.noreply.github.com> Date: Thu, 10 Aug 2023 13:00:52 +0200 Subject: [PATCH] graphql: validate block params (#27876) Block takes a number and a hash. The spec is unclear on what should happen in this case, leaving it an implemenation detail. With this change, we return an error in case both number and hash are passed in. --- graphql/graphql.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/graphql/graphql.go b/graphql/graphql.go index 7aa427b45..6417fc9ed 100644 --- a/graphql/graphql.go +++ b/graphql/graphql.go @@ -1217,6 +1217,9 @@ func (r *Resolver) Block(ctx context.Context, args struct { Number *Long Hash *common.Hash }) (*Block, error) { + if args.Number != nil && args.Hash != nil { + return nil, errors.New("only one of number or hash must be specified") + } var numberOrHash rpc.BlockNumberOrHash if args.Number != nil { if *args.Number < 0 {