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

Don't return stacktrace as part of the response #21443

Merged
merged 2 commits into from
Jan 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

from airbyte_cdk.models import AirbyteLogMessage, AirbyteMessage, Type
from airbyte_cdk.utils.schema_inferrer import SchemaInferrer

from connector_builder.generated.apis.default_api_interface import DefaultApi
from connector_builder.generated.models.http_request import HttpRequest
from connector_builder.generated.models.http_response import HttpResponse
Expand Down Expand Up @@ -104,6 +103,8 @@ async def list_streams(self, streams_list_request_body: StreamsListRequestBody =
)
)
except Exception as error:
self.logger.error(
f"Could not list streams with with error: {error.args[0]} - {DefaultApiImpl._get_stacktrace_as_string(error)}")
raise HTTPException(status_code=400, detail=f"Could not list streams with with error: {error.args[0]}")
return StreamsListRead(streams=stream_list_read)

Expand Down Expand Up @@ -137,14 +138,17 @@ async def read_stream(self, stream_read_request_body: StreamReadRequestBody = Bo
single_slice.pages.append(message_group)
except Exception as error:
# TODO: We're temporarily using FastAPI's default exception model. Ideally we should use exceptions defined in the OpenAPI spec
self.logger.error(f"Could not perform read with with error: {error.args[0]} - {self._get_stacktrace_as_string(error)}")
raise HTTPException(
status_code=400,
detail=f"Could not perform read with with error: {error.args[0]} - {self._get_stacktrace_as_string(error)}",
detail=f"Could not perform read with with error: {error.args[0]}",
)

return StreamRead(logs=log_messages, slices=[single_slice], inferred_schema=schema_inferrer.get_stream_schema(stream_read_request_body.stream))
return StreamRead(logs=log_messages, slices=[single_slice],
inferred_schema=schema_inferrer.get_stream_schema(stream_read_request_body.stream))

def _get_message_groups(self, messages: Iterator[AirbyteMessage], schema_inferrer: SchemaInferrer, limit: int) -> Iterable[Union[StreamReadPages, AirbyteLogMessage]]:
def _get_message_groups(self, messages: Iterator[AirbyteMessage], schema_inferrer: SchemaInferrer, limit: int) -> Iterable[
Union[StreamReadPages, AirbyteLogMessage]]:
"""
Message groups are partitioned according to when request log messages are received. Subsequent response log messages
and record messages belong to the prior request log message and when we encounter another request, append the latest
Expand Down Expand Up @@ -227,9 +231,10 @@ def _create_low_code_adapter(self, manifest: Dict[str, Any]) -> CdkAdapter:
return self.adapter_cls(manifest=manifest)
except ValidationError as error:
# TODO: We're temporarily using FastAPI's default exception model. Ideally we should use exceptions defined in the OpenAPI spec
self.logger.error(f"Invalid connector manifest with error: {error.message} - {DefaultApiImpl._get_stacktrace_as_string(error)}")
raise HTTPException(
status_code=400,
detail=f"Invalid connector manifest with error: {error.message} - {DefaultApiImpl._get_stacktrace_as_string(error)}",
detail=f"Invalid connector manifest with error: {error.message}",
)

@staticmethod
Expand Down