Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphQL::Schema::UniqueWithinType error handling missing for Base64Encoder #3177

Closed
grvillic opened this issue Oct 2, 2020 · 1 comment
Closed

Comments

@grvillic
Copy link
Contributor

grvillic commented Oct 2, 2020

Describe the bug

We are seeing ArgumentError logs in here due to missing proper error handling.

Versions

graphql version: 1.11.1
rails (or other framework): 2.7

GraphQL schema

Include relevant types and fields (in Ruby is best, in GraphQL IDL is ok).
Are you using interpreter? Any custom instrumentation, etc?

def decode(node_id, separator: self.default_id_separator)
   #  error handling missing below
    Base64Bp.urlsafe_decode64(node_id).split(separator, 2)
end

Steps to reproduce

  • Pass an invalid node_id that is not a valid Base64 Encoded string.

Expected behavior

Operation should log decoding issue. Use Base64Encoder utility that already has argument error handling.

Actual behavior

ArgumentError is being thrown without providing insights about the invalid string.

What specifically went wrong?

Click to view exception backtrace ``` ArgumentError invalid base64 :281:in `unpack1' /usr/local/lib/ruby/2.7.0/base64.rb:74:in `strict_decode64' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/schema/base_64_bp.rb:24:in `urlsafe_decode64' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/schema/unique_within_type.rb:31:in `decode' /src/app/app/graphql/api/schema.rb:25:in `object_from_id' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/schema.rb:670:in `call' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/schema.rb:670:in `object_from_id' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/types/relay/node_field.rb:34:in `resolve' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/types/relay/node_field.rb:38:in `resolve_field' /src/app/lib/graphql_timer.rb:26:in `call' /src/app/lib/graphql_timer.rb:26:in `block (2 levels) in instrument' /src/app/vendor/gems/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/notifications.rb:180:in `block in instrument' /src/app/vendor/gems/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/notifications/instrumenter.rb:24:in `instrument' /src/app/vendor/gems/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/notifications.rb:180:in `instrument' /src/app/lib/graphql_timer.rb:25:in `block in instrument' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/schema/member/instrumentation.rb:80:in `call' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/field.rb:136:in `resolve' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/execution/execute.rb:321:in `call' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/schema/middleware_chain.rb:49:in `invoke_core' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/schema/middleware_chain.rb:38:in `invoke' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/execution/execute.rb:129:in `block in resolve_field' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/tracing.rb:66:in `trace' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/execution/execute.rb:128:in `resolve_field' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/execution/execute.rb:92:in `block in resolve_selection' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/execution/execute.rb:85:in `each' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/execution/execute.rb:85:in `resolve_selection' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/execution/execute.rb:56:in `block in resolve_root_selection' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/tracing.rb:66:in `trace' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/execution/execute.rb:49:in `resolve_root_selection' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/execution/execute.rb:31:in `begin_query' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/execution/multiplex.rb:112:in `begin_query' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/execution/multiplex.rb:83:in `block in run_as_multiplex' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/execution/multiplex.rb:82:in `map' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/execution/multiplex.rb:82:in `run_as_multiplex' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/execution/multiplex.rb:61:in `block (2 levels) in run_queries' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/execution/multiplex.rb:195:in `block in instrument_and_analyze' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/execution/instrumentation.rb:29:in `block (2 levels) in apply_instrumenters' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/execution/instrumentation.rb:46:in `block (2 levels) in each_query_call_hooks' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/execution/instrumentation.rb:41:in `each_query_call_hooks' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/execution/instrumentation.rb:45:in `block in each_query_call_hooks' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/execution/instrumentation.rb:72:in `call_hooks' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/execution/instrumentation.rb:44:in `each_query_call_hooks' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/execution/instrumentation.rb:27:in `block in apply_instrumenters' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/execution/instrumentation.rb:72:in `call_hooks' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/execution/instrumentation.rb:26:in `apply_instrumenters' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/execution/multiplex.rb:174:in `instrument_and_analyze' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/execution/multiplex.rb:60:in `block in run_queries' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/tracing.rb:66:in `trace' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/execution/multiplex.rb:58:in `run_queries' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/query.rb:194:in `block in result' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/query.rb:438:in `with_prepared_ast' /src/app/vendor/gems/ruby/2.7.0/gems/graphql-1.11.1/lib/graphql/query.rb:193:in `result' ```
@rmosolgo
Copy link
Owner

rmosolgo commented Oct 5, 2020

Fixed by #3179

@rmosolgo rmosolgo closed this as completed Oct 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants