Skip to content

Commit

Permalink
fix(CE): validate_catalog disabled query_source (#356)
Browse files Browse the repository at this point in the history
Co-authored-by: afthab vp <[email protected]>
  • Loading branch information
github-actions[bot] and afthabvp authored Sep 4, 2024
1 parent 5a2b57c commit d11a780
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
3 changes: 2 additions & 1 deletion server/app/controllers/api/v1/connectors_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 13 additions & 13 deletions server/spec/requests/api/v1/connectors_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d11a780

Please sign in to comment.