Get /users/by-external/ throwing URL Not Found error after update

i was actually able to solve it

Seems they updated the code to actually throw an error if no user is found so i had to rescue instead of compare if nil?

begin
    resp = client.get("/users/by-external/#{user.id}")
rescue DiscourseApi::NotFoundError => error
    puts error.response.body['errors'].first
    sync_user(user)
else
    resp.response.env.body['user']
end

also the response has changed from
resp['body']['user']
to
resp.response.env.body['user']

my last remaining problem is that when i call client.sync_sso i get a Internal server error 500 now

The logs show
ActiveRecord::RecordNotUnique (PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "user_emails_pkey"

However, if i use the exact same details in the rails terminal and run client.sync_sso it runs perfectly fine

Just FYI i didn’t change the endpoint for the above parts to start working again so it seems the /users/by-external/ is still valid