Skip to content

fix: properly show error when failing to fetch shape data#1353

Open
firestack wants to merge 1 commit intomasterfrom
kf/jj/umqrkyznrymz
Open

fix: properly show error when failing to fetch shape data#1353
firestack wants to merge 1 commit intomasterfrom
kf/jj/umqrkyznrymz

Conversation

@firestack
Copy link
Member

Summary of changes

Asana Ticket: No Ticket

There's a situation in Arrow where a file can be deleted from S3, but Arrow still tries to retrieve it, and marks it as an error if it fails to retrieve it, if the shuttle is considered 'active'.

There is error handling for this case, but it turns out we're calling Ecto.Changeset.add_error/4 incorrectly, by passing the error term we're returned from various systems into the "message" argument, which is incorrect per the function requirements. This ends up with errors like this in the logs:

6b3edd887268 20:06:48.216 [error] #PID<0.28077.0> running ArrowWeb.Endpoint (connection #PID<0.28067.0>, stream id 2) terminated

6b3edd887268 Server: arrow-dev.mbtace.com:80 (http)

6b3edd887268 Request: GET /shuttles/18/edit

6b3edd887268 ** (exit) an exception was raised:

6b3edd887268 ** (FunctionClauseError) no function clause matching in Ecto.Changeset.add_error/4

6b3edd887268 (ecto 3.13.2) lib/ecto/changeset.ex:2407: Ecto.Changeset.add_error(#Ecto.Changeset<action: nil, changes: %{}, errors: [], data: #Arrow.Shuttles.Route<>, valid?: true, ...>, :shape_id, {:http_error, 404, %{body: "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message><Key>dev/shape-uploads/MedfordTuftsToGovernmentCenter-S.kml</Key><RequestId>2FY1B4K8VG3HWXRG</RequestId><HostId>j8aLLsEDXDRn+gtdYvpeIrAF5iAEkQguqmsN7A3hAYxJycZCczbGjCpxAG7mXJUkSzY5tZ7n9jxNmGTICPa8kBVMnY6EUC1erL7CgSbKPPo=</HostId></Error>", headers: [{"x-amz-request-id", "2FY1B4K8VG3HWXRG"}, {"x-amz-id-2", "j8aLLsEDXDRn+gtdYvpeIrAF5iAEkQguqmsN7A3hAYxJycZCczbGjCpxAG7mXJUkSzY5tZ7n9jxNmGTICPa8kBVMnY6EUC1erL7CgSbKPPo="}, {"Content-Type", "application/xml"}, {"Transfer-Encoding", "chunked"}, {"Date", "Mon, 02 Feb 2026 20:06:47 GMT"}, {"Server", "AmazonS3"}], status_code: 404}}, [])

6b3edd887268 (arrow 0.1.0) lib/arrow/shuttles/route.ex:51: Arrow.Shuttles.Route.changeset/3

I assume previous implementers intended any errors to bubble up into the form, per Phoenix/Liveview/Ecto conventions, but by calling add_error wrong, we're crashing the process and preventing the UI from doing anything or making the failure state understandable.

This serializes the error using inspect which allows the error to be surfaced to the frontend.


Before: Internal server error

After:
image

Reviewer Checklist

  • Meets ticket's acceptance criteria
  • Any new or changed functions have typespecs
  • Tests were added for any new functionality (don't just rely on Codecov)
  • This branch was deployed to the staging environment and is currently running with no unexpected increase in warnings, and no errors or crashes.

@firestack firestack requested a review from a team as a code owner February 2, 2026 21:12
@firestack firestack requested review from rudiejd and removed request for a team February 2, 2026 21:12
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

Successfully merging this pull request may close these issues.

1 participant