From d11a7801fe61009cf6a02285bfc434276dbeb0cc Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 4 Sep 2024 11:16:38 +0530 Subject: [PATCH] fix(CE): validate_catalog disabled query_source (#356) Co-authored-by: afthab vp --- .../api/v1/connectors_controller.rb | 3 ++- .../api/v1/connectors_controller_spec.rb | 26 +++++++++---------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/server/app/controllers/api/v1/connectors_controller.rb b/server/app/controllers/api/v1/connectors_controller.rb index 77bbcd08..821a99f7 100644 --- a/server/app/controllers/api/v1/connectors_controller.rb +++ b/server/app/controllers/api/v1/connectors_controller.rb @@ -8,7 +8,8 @@ class ConnectorsController < ApplicationController before_action :set_connector, only: %i[show update destroy discover query_source] # TODO: Enable this once we have query validation implemented for all the connectors # before_action :validate_query, only: %i[query_source] - before_action :validate_catalog, only: %i[query_source] + # TODO: Enable this for ai_ml sources + # before_action :validate_catalog, only: %i[query_source] after_action :event_logger def index diff --git a/server/spec/requests/api/v1/connectors_controller_spec.rb b/server/spec/requests/api/v1/connectors_controller_spec.rb index e5f194b1..02f9da27 100644 --- a/server/spec/requests/api/v1/connectors_controller_spec.rb +++ b/server/spec/requests/api/v1/connectors_controller_spec.rb @@ -481,19 +481,19 @@ expect(response_hash[:data]).to eq([record1.record.data, record2.record.data]) end - it "returns an error message for missing catalog" do - catalog = connector.catalog - catalog.connector_id = connectors.second.id - catalog.save - - allow(Connectors::QuerySource).to receive(:call).and_return(double(:context, success?: true, - records: [record1, record2])) - post "/api/v1/connectors/#{connector.id}/query_source", params: request_body.to_json, headers: - { "Content-Type": "application/json" }.merge(auth_headers(user, workspace.id)) - expect(response).to have_http_status(:unprocessable_entity) - response_hash = JSON.parse(response.body).with_indifferent_access - expect(response_hash.dig(:errors, 0, :detail)).to eq("Catalog is not present for the connector") - end + # it "returns an error message for missing catalog" do + # catalog = connector.catalog + # catalog.connector_id = connectors.second.id + # catalog.save + + # allow(Connectors::QuerySource).to receive(:call).and_return(double(:context, success?: true, + # records: [record1, record2])) + # post "/api/v1/connectors/#{connector.id}/query_source", params: request_body.to_json, headers: + # { "Content-Type": "application/json" }.merge(auth_headers(user, workspace.id)) + # expect(response).to have_http_status(:unprocessable_entity) + # response_hash = JSON.parse(response.body).with_indifferent_access + # expect(response_hash.dig(:errors, 0, :detail)).to eq("Catalog is not present for the connector") + # end it "returns success status for a valid query for viewer role" do workspace.workspace_users.first.update(role: viewer_role)