Skip to content

External subscription-check is broken #241

@kevinbader

Description

@kevinbader

Piotr Kłoskowski via Slack:


I want to introduce an external endpoint for subscription validation, hence I set the environment variable as follows (testing locally on docker, latest RIG release, running cypress automated tests)
Changes to docker-compose:
app.docker-compose.yaml

SUBSCRIPTION_CHECK=http://validator/validate

And

  validator:
    container_name: validator
    image: pkloskowski/validator:latest
    ports:
      - 80:80
    depends_on:
      - rig

Validator is a simple service that accepts POST requests, log headers and body and returns 200)

So when I re-run tests with this new config I get the following 500 on RIG while trying to subscribe (looks like parsing/converting error, there are no calls to my validator service):

18:59:01.658 [info]  PUT /_rig/v1/connection/ws/r5TW5oLH8gNoC_CaMeZKnIRu08_ysKejMUHFcbMpTPy2vwKvyHoFggwvapu4mdHHOmKkAgH-Lml2Hto=/subscriptions
request_id=FbaS_lhI45bmW7oAAAFi application=plug module=Plug.Logger function=call/2 file=lib/plug/logger.ex line=27 pid=<0.2348.0>

18:59:01.658 [debug] PUT /_rig/v1/connection/ws/r5TW5oLH8gNoC_CaMeZKnIRu08_ysKejMUHFcbMpTPy2vwKvyHoFggwvapu4mdHHOmKkAgH-Lml2Hto=/subscriptions
request_id=FbaS_lhI45bmW7oAAAFi application=plug module=Plug.Logger function=call/2 file=lib/plug/logger.ex line=27 pid=<0.2348.0>

18:59:01.659 [debug] Processing with RigInboundGatewayWeb.V1.SubscriptionController.set_subscriptions/2
  Parameters: [UNFETCHED]
  Pipelines: [:api]
request_id=FbaS_lhI45bmW7oAAAFi application=phoenix module=Phoenix.Logger function=phoenix_controller_call/3 file=lib/phoenix/logger.ex line=47 pid=<0.2348.0>

18:59:01.671 [info]  Converted error {:case_clause, %Plug.Conn.Unfetched{aspect: :body_params}} to 500 response
request_id=FbaS_lhI45bmW7oAAAFi application=phoenix module=Phoenix.Logger function=phoenix_error_render/3 file=lib/phoenix/logger.ex line=35 pid=<0.2348.0>
:gen_event handler Logger.Backends.Console installed in Logger terminating
** (exit) an exception was raised:
    ** (Protocol.UndefinedError) protocol String.Chars not implemented for {%CaseClauseError{term: %Plug.Conn.Unfetched{aspect: :body_params}}, [{:hackney_request, :handle_body, 4, [file: '/opt/sites/rig/deps/hackney/src/hackney_request.erl', line: 318]}, {:hackney_request, :perform, 2, [file: '/opt/sites/rig/deps/hackney/src/hackney_request.erl', line: 83]}, {:hackney, :send_request, 2, [file: '/opt/sites/rig/deps/hackney/src/hackney.erl', line: 373]}, {HTTPoison.Base, :request, 6, [file: 'lib/httpoison/base.ex', line: 787]}, {RigAuth.AuthorizationCheck.External, :check, 3, [file: 'lib/rig_auth/authorization_check/external.ex', line: 19]}, {RigAuth.AuthorizationCheck.External, :check_or_log, 3, [file: 'lib/rig_auth/authorization_check/external.ex', line: 30]}, {RigInboundGatewayWeb.V1.SubscriptionController, :do_set_subscriptions, 2, [file: 'lib/rig_inbound_gateway_web/v1/subscription_controller.ex', line: 122]}, {RigInboundGatewayWeb.V1.SubscriptionController, :action, 2, [file: 'lib/rig_inbound_gateway_web/v1/subscription_controller.ex', line: 1]}]}. This protocol is implemented for: Atom, BitString, Date, DateTime, Float, Integer, List, NaiveDateTime, Rig.Subscription, Time, URI, Version, Version.Requirement
        (elixir) /usr/local/src/elixir/lib/elixir/lib/string/chars.ex:3: String.Chars.impl_for!/1
        (elixir) /usr/local/src/elixir/lib/elixir/lib/string/chars.ex:22: String.Chars.to_string/1
        (logger) lib/logger/formatter.ex:166: anonymous fn/1 in Logger.Formatter.output/5
        (elixir) lib/enum.ex:1314: Enum."-map/2-lists^map/1-0-"/2
        (elixir) lib/enum.ex:1314: Enum."-map/2-lists^map/1-0-"/2
        (logger) lib/logger/formatter.ex:152: anonymous fn/6 in Logger.Formatter.format/5
        (elixir) lib/enum.ex:1925: Enum."-reduce/3-lists^foldl/2-0-"/3
        (logger) lib/logger/formatter.ex:151: Logger.Formatter.format/5

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions