SlideShare a Scribd company logo
1 of 54
Download to read offline
Call for a better error handling in APIs
André Cedik · Developer Advocate
shipcloud.io · andre@shipcloud.io
shipcloud GmbH · Mittelweg 162 20148 Hamburg
API v2
• Incoporate learnings from more than 5 years
• Easier integration in existing shop- / ERP-software
• I18n
• Returning translated strings
• White label
• Design first approach using OpenAPI
But most of all ...
... better error communication!
shipcloud error communication
History of errors
Mariner 1
• Veered off course, because
unscheduled maneuver
• Steering unpossible
• Missing hyphen in the code
allowed transmission of
incorrect guidance signals
• Engineers hit self destruct
button
• $18 million error
ESA Ariane 5
Flight 501
• Reused software from
Ariane 4
• Ariane 5 had faster engines
• Software tried to push a
64-bit float into a signed 16-
bit integer
• Engineers hit self destruct
button at 37 sec. into its
maiden launch
• $8 billion error
NASA Mars
Climate Orbiter
• Failed conversion from
imperial units to metric
• Send the orbiter too close
to Mars‘ surface
• $125 million error
Y2K Bug
• Year numbers where saved with 2
digits (98,99,00,01)
• No one knew what will happen
when the year 2000 sets in
• Since ‘00‘ also meant 1900
• $500 billion error
Pentium-FDIV-Bug
• In 1994 Math Prof. Thomas R.
Nicely reported the bug
• Processor might return incorrect
binary floating point results when
dividing a number
• Intel attributed error to missing
entries in the lookup table
• Tried to downplay the bug
• Had to replace processors
• $475 million error
Miscommunication
Mokusatsu - The World‘s Most Tragic
Translation
• Allied leaders called for Japan’s
unconditional surrender
• Japanese government said
nothing while considering their
options
• PM Kantaro Suzuki was
pressured for comment
• said only one word "mokusatsu“
• Mistranslation leads to the
dropping of the atomic bomb
Hawaii Missle Strike
• In Jan. 2018 citizens of Hawaii were
warned of an inbound ballistic
missile strike
• Turned out to be a false alert
• Recording over phone „EXERCISE“
• Message with „THIS IS NOT A
DRILL“
• Same UI used for drill and real
alerts
• No safeguards were in place
• It took 38 minutes to retract the
alert, because there was no
response protocol for a false alert
Error handling in APIs
Tools used at the moment
"Building fault-tolerant software
boils down to detecting errors
and doing something when
errors are detected"
Joe Armstrong, inventor of Erlang
http response status codes
• Informational 1xx
• Successful 2xx
• 200 OK
• Redirection 3xx
• 301 Moved Permanently
• Client Error 4xx
• Server Error 5xx
http response status codes 4xx & 5xx
• 400 Bad Request
• 402 Payment Required
• 403 Forbidden
• 404 Not Found
• 500 Internal Server Error
• 502 Bad Gateway
• 504 Gateway Timeout
Error handling in the body
• Good:
• Return complex structures
• Get more specific about an error
• Convey multiple errors
• Bad:
• Everyone has their own way of doing it
• Therefore developers have to understand „the way“
Error handling in APIs
The bad
shipcloud error communication
Sabre Dev Studio – error attribute
• „error“ is always a string
• Sometimes all Uppercase -
> seems to be like an error
code
Sabre Dev Studio – error attribute
• „error“ is always a string
• Sometimes all Uppercase -
> seems to be like an error
code
• Sometimes it looks like an
error trace
Sabre Dev Studio – code attribute
• Sometimes it looks like a
http response status code
• Sometimes like an internal
code
• Same code used more than
once
• different error text
• 102
• 111
• 404
• 500
• 700101
• 050002
• 060016
• 700202
Sabre Dev Studio – code attribute
Pitney Bowes
• Each validated field has its own
error code
Pitney Bowes
• Each validated field has its own
error code
• "XXX is invalid, unsupported or
missing“
• So what is it now?!?
Google Maps Geocoding API
• Has a „status“ attribute
• OK, ZERO_RESULTS, OVER_DAILY_LIMIT, OVER_QUERY_LIMIT,
REQUEST_DENIED, INVALID_REQUEST, UNKNOWN_ERROR
• INVALID_REQUEST = 400 Bad Request
• OVER_QUERY_LIMIT = 200 OK
Google Drive API v3
Klarna
API Football
Error handling in APIs
The good parts
squarespace
Facebook GraphAPI
Facebook Marketing API
Facebook Marketing API
Banks API
Figo.io
What we can do better
What‘s the problem?
• „API calls either fail or are successful“ – Phil Sturgeon
• „Soft errors“
• Not an exception type „crash“
• More like a warning
application/problem+json
• RFC 7807
• Pros
• Own content type
• Predefined set of attributes
• Extensible
• Cons
• Not encapsulated
• Mixing with other content
• Multi error handling just for
one error type
HTTP/1.1 403 Forbidden
Content-Type: application/problem+json
Content-Language: en
{
"type": "https://example.com/probs/out-of-credit",
"title": "You do not have enough credit.",
"detail": "Your current balance is 30, but that costs 50.",
"instance": "/account/12345/msgs/abc",
"balance": 30,
"accounts": ["/account/12345",
"/account/67890"]
}
Warning header
• RFC 7234
• Pros
• You could handle „soft
errors“
• Multiple warning header for
multiple different errors
• Cons
• Complex data can‘t be
returned
• It‘s just a string
HTTP/1.1 200 OK
Date: Sat, 25 Aug 2012 23:34:45 GMT
Warning: 112 - "network down" "Sat, 25 Aug 2012 23:34:45
GMT"
application/health+json
• Internet Draft inadarei-api-
health-check
• Pros
• „status“ attribute („pass“,
„warn“, „error“)
• Cons
• Specific to health of an api
• Overhead content
HTTP/1.1 200 OK
Content-Type: application/health+json
{
"status": "pass",
"version": "1",
"releaseId": "1.2.2",
"notes": [""],
"output": "",
"serviceId": "f03e522f-1f44-4062-9b55-9587f91c9c41",
"description": "health of authz service",
"checks": {
"cassandra:responseTime": [
{
"componentId": "dfd6cf2b-1b6e-4412-a0b8-f6f7797a60d2",
"componentType": "datastore",
"observedValue": 250,
"observedUnit": "ms",
"status": "pass",
"affectedEndpoints" : [
"/users/{userId}",
"/customers/{customerId}/status",
"/shopping/{anything}"
],
"time": "2018-01-17T03:36:48Z",
"output": ""
}
application/vnd.api+json
• JSON:API standard
• Pros
• Errors array to handle
multiple errors
• JSON pointers to show devs
where an error has occurred
• Cons
• Everything is in errors object
• „soft errors“ not possible
Best current practice
• HTTP status code
• Error object
• Easy referencing of errors
• „Code“
• „Subcode“
• Request IDs in the body
• for easier request identification in support cases
• Human readable message
• In multiple languages
"An excellent error message is
precise and lets the user know
about the nature of the error so
that they can figure their way
out of it."
Guy Levin, RestCase
Future of error handling in
APIs
A proposal
A proposal – to be discussed
A proposal – to be discussed
• Responses in a new format
• „data“ holds everything
we‘d normally have in the
root
• „errors“ and „warnings“
give information about
what happened
• „errors“ and „warnings“
follow the RFC 7807
pattern
A proposal – to be discussed
• „data“ is empty since no
resource was created
• Warnings possible if api
supports this use case
Questions?
Open Discussion
@andrecedik
Sources
• Atlas Agena with Mariner 1: NASA,
https://commons.wikimedia.org/wiki/File:Atlas_Agena_with_Mariner_1.jpg
• Ariane 5: DLR German Aerospace Center,
https://www.flickr.com/photos/48213136@N06/8958839420
• Mars Climate Orbiter: NASA/JPL/Corby Waste,
https://commons.wikimedia.org/wiki/File:Mars_Climate_Orbiter_2.jpg
• Bug de l'an 2000: https://commons.wikimedia.org/wiki/File:Bug_de_l%27an_2000.jpg
• Pentium: Konstantin Lanzet,
https://commons.wikimedia.org/wiki/File:KL_Intel_Pentium_A80501.jpg
• Hawaii Missle Alert SMS: https://twitter.com/tulsigabbard/status/952243723525677056

More Related Content

What's hot

Innovation dank DevOps (DevOpsCon Berlin 2015)
Innovation dank DevOps (DevOpsCon Berlin 2015)Innovation dank DevOps (DevOpsCon Berlin 2015)
Innovation dank DevOps (DevOpsCon Berlin 2015)Wooga
 
How to Test Security and Vulnerability of Your Android and iOS Apps
How to Test Security and Vulnerability of Your Android and iOS AppsHow to Test Security and Vulnerability of Your Android and iOS Apps
How to Test Security and Vulnerability of Your Android and iOS AppsBitbar
 
The Status of Android Hardware and Software - From App Developer's Point of View
The Status of Android Hardware and Software - From App Developer's Point of ViewThe Status of Android Hardware and Software - From App Developer's Point of View
The Status of Android Hardware and Software - From App Developer's Point of ViewBitbar
 
Building a scalable API with Grails
Building a scalable API with GrailsBuilding a scalable API with Grails
Building a scalable API with GrailsTanausu Cerdeña
 
How to Leverage Appium in Your Mobile App Testing
How to Leverage Appium in Your Mobile App TestingHow to Leverage Appium in Your Mobile App Testing
How to Leverage Appium in Your Mobile App TestingBitbar
 
Get step-by-step instructions on implementing notifications in your apps.
Get step-by-step instructions on implementing notifications in your apps.Get step-by-step instructions on implementing notifications in your apps.
Get step-by-step instructions on implementing notifications in your apps.Jigar Maheshwari
 
Serverless in production, an experience report (Going Serverless)
Serverless in production, an experience report (Going Serverless)Serverless in production, an experience report (Going Serverless)
Serverless in production, an experience report (Going Serverless)Yan Cui
 
Different Android Test Automation Frameworks - What Works You the Best?
Different Android Test Automation Frameworks - What Works You the Best?Different Android Test Automation Frameworks - What Works You the Best?
Different Android Test Automation Frameworks - What Works You the Best?Bitbar
 
An Introduction To Automated API Testing
An Introduction To Automated API TestingAn Introduction To Automated API Testing
An Introduction To Automated API TestingSauce Labs
 
CMG imPACt2016 - Mobile performance testing - Vendor training - Federico Tole...
CMG imPACt2016 - Mobile performance testing - Vendor training - Federico Tole...CMG imPACt2016 - Mobile performance testing - Vendor training - Federico Tole...
CMG imPACt2016 - Mobile performance testing - Vendor training - Federico Tole...Federico Toledo
 
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)Bitbar
 

What's hot (12)

Innovation dank DevOps (DevOpsCon Berlin 2015)
Innovation dank DevOps (DevOpsCon Berlin 2015)Innovation dank DevOps (DevOpsCon Berlin 2015)
Innovation dank DevOps (DevOpsCon Berlin 2015)
 
How to Test Security and Vulnerability of Your Android and iOS Apps
How to Test Security and Vulnerability of Your Android and iOS AppsHow to Test Security and Vulnerability of Your Android and iOS Apps
How to Test Security and Vulnerability of Your Android and iOS Apps
 
The Status of Android Hardware and Software - From App Developer's Point of View
The Status of Android Hardware and Software - From App Developer's Point of ViewThe Status of Android Hardware and Software - From App Developer's Point of View
The Status of Android Hardware and Software - From App Developer's Point of View
 
Building a scalable API with Grails
Building a scalable API with GrailsBuilding a scalable API with Grails
Building a scalable API with Grails
 
How to Leverage Appium in Your Mobile App Testing
How to Leverage Appium in Your Mobile App TestingHow to Leverage Appium in Your Mobile App Testing
How to Leverage Appium in Your Mobile App Testing
 
Get step-by-step instructions on implementing notifications in your apps.
Get step-by-step instructions on implementing notifications in your apps.Get step-by-step instructions on implementing notifications in your apps.
Get step-by-step instructions on implementing notifications in your apps.
 
ruxc0n 2012
ruxc0n 2012ruxc0n 2012
ruxc0n 2012
 
Serverless in production, an experience report (Going Serverless)
Serverless in production, an experience report (Going Serverless)Serverless in production, an experience report (Going Serverless)
Serverless in production, an experience report (Going Serverless)
 
Different Android Test Automation Frameworks - What Works You the Best?
Different Android Test Automation Frameworks - What Works You the Best?Different Android Test Automation Frameworks - What Works You the Best?
Different Android Test Automation Frameworks - What Works You the Best?
 
An Introduction To Automated API Testing
An Introduction To Automated API TestingAn Introduction To Automated API Testing
An Introduction To Automated API Testing
 
CMG imPACt2016 - Mobile performance testing - Vendor training - Federico Tole...
CMG imPACt2016 - Mobile performance testing - Vendor training - Federico Tole...CMG imPACt2016 - Mobile performance testing - Vendor training - Federico Tole...
CMG imPACt2016 - Mobile performance testing - Vendor training - Federico Tole...
 
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)
 

Similar to Call for a better error handling in APIs

System insight without Interference
System insight without InterferenceSystem insight without Interference
System insight without InterferenceTony Tam
 
Android lessons you won't learn in school
Android lessons you won't learn in schoolAndroid lessons you won't learn in school
Android lessons you won't learn in schoolMichael Galpin
 
Создание API, которое полюбят разработчики. Глубокое погружение
Создание API, которое полюбят разработчики. Глубокое погружениеСоздание API, которое полюбят разработчики. Глубокое погружение
Создание API, которое полюбят разработчики. Глубокое погружениеSQALab
 
Coding 100-session-slides
Coding 100-session-slidesCoding 100-session-slides
Coding 100-session-slidesCisco DevNet
 
Embracing HTTP in the era of API’s
Embracing HTTP in the era of API’sEmbracing HTTP in the era of API’s
Embracing HTTP in the era of API’sVisug
 
Architecture app
Architecture appArchitecture app
Architecture appYnon Perek
 
Api fundamentals
Api fundamentalsApi fundamentals
Api fundamentalsAgileDenver
 
Api FUNdamentals #MHA2017
Api FUNdamentals #MHA2017Api FUNdamentals #MHA2017
Api FUNdamentals #MHA2017JoEllen Carter
 
Cross-platform logging and analytics
Cross-platform logging and analyticsCross-platform logging and analytics
Cross-platform logging and analyticsDrew Crawford
 
Spsbe2012 sessie start to-jquery
Spsbe2012 sessie start to-jquerySpsbe2012 sessie start to-jquery
Spsbe2012 sessie start to-jqueryMarijn Somers
 
Heartbleed Bug Vulnerability: Discovery, Impact and Solution
Heartbleed Bug Vulnerability: Discovery, Impact and SolutionHeartbleed Bug Vulnerability: Discovery, Impact and Solution
Heartbleed Bug Vulnerability: Discovery, Impact and SolutionCASCouncil
 
Php Debugging from the Trenches
Php Debugging from the TrenchesPhp Debugging from the Trenches
Php Debugging from the TrenchesSimon Jones
 
CI/CD and Asset Serving for Single Page Apps
CI/CD and Asset Serving for Single Page AppsCI/CD and Asset Serving for Single Page Apps
CI/CD and Asset Serving for Single Page AppsMike North
 
Cross-Platform Desktop Apps with Electron (CodeStock Edition)
Cross-Platform Desktop Apps with Electron (CodeStock Edition)Cross-Platform Desktop Apps with Electron (CodeStock Edition)
Cross-Platform Desktop Apps with Electron (CodeStock Edition)David Neal
 
Hacking Robots for Fun and Profit
Hacking Robots for Fun and ProfitHacking Robots for Fun and Profit
Hacking Robots for Fun and ProfitChad Udell
 
Hacking Robots for Fun and Profit
Hacking Robots for Fun and ProfitHacking Robots for Fun and Profit
Hacking Robots for Fun and ProfitChad Udell
 
Hacking Adobe Experience Manager sites
Hacking Adobe Experience Manager sitesHacking Adobe Experience Manager sites
Hacking Adobe Experience Manager sitesMikhail Egorov
 
Доклад Михаила Егорова на PHDays
Доклад Михаила Егорова на PHDaysДоклад Михаила Егорова на PHDays
Доклад Михаила Егорова на PHDaysru_Parallels
 

Similar to Call for a better error handling in APIs (20)

System insight without Interference
System insight without InterferenceSystem insight without Interference
System insight without Interference
 
Android lessons you won't learn in school
Android lessons you won't learn in schoolAndroid lessons you won't learn in school
Android lessons you won't learn in school
 
Создание API, которое полюбят разработчики. Глубокое погружение
Создание API, которое полюбят разработчики. Глубокое погружениеСоздание API, которое полюбят разработчики. Глубокое погружение
Создание API, которое полюбят разработчики. Глубокое погружение
 
Coding 100-session-slides
Coding 100-session-slidesCoding 100-session-slides
Coding 100-session-slides
 
Embracing HTTP in the era of API’s
Embracing HTTP in the era of API’sEmbracing HTTP in the era of API’s
Embracing HTTP in the era of API’s
 
Architecture app
Architecture appArchitecture app
Architecture app
 
Api fundamentals
Api fundamentalsApi fundamentals
Api fundamentals
 
Api FUNdamentals #MHA2017
Api FUNdamentals #MHA2017Api FUNdamentals #MHA2017
Api FUNdamentals #MHA2017
 
Cross-platform logging and analytics
Cross-platform logging and analyticsCross-platform logging and analytics
Cross-platform logging and analytics
 
Spsbe2012 sessie start to-jquery
Spsbe2012 sessie start to-jquerySpsbe2012 sessie start to-jquery
Spsbe2012 sessie start to-jquery
 
Heartbleed Bug Vulnerability: Discovery, Impact and Solution
Heartbleed Bug Vulnerability: Discovery, Impact and SolutionHeartbleed Bug Vulnerability: Discovery, Impact and Solution
Heartbleed Bug Vulnerability: Discovery, Impact and Solution
 
Hacking Wordpress Plugins
Hacking Wordpress PluginsHacking Wordpress Plugins
Hacking Wordpress Plugins
 
Php Debugging from the Trenches
Php Debugging from the TrenchesPhp Debugging from the Trenches
Php Debugging from the Trenches
 
Swift meetup22june2015
Swift meetup22june2015Swift meetup22june2015
Swift meetup22june2015
 
CI/CD and Asset Serving for Single Page Apps
CI/CD and Asset Serving for Single Page AppsCI/CD and Asset Serving for Single Page Apps
CI/CD and Asset Serving for Single Page Apps
 
Cross-Platform Desktop Apps with Electron (CodeStock Edition)
Cross-Platform Desktop Apps with Electron (CodeStock Edition)Cross-Platform Desktop Apps with Electron (CodeStock Edition)
Cross-Platform Desktop Apps with Electron (CodeStock Edition)
 
Hacking Robots for Fun and Profit
Hacking Robots for Fun and ProfitHacking Robots for Fun and Profit
Hacking Robots for Fun and Profit
 
Hacking Robots for Fun and Profit
Hacking Robots for Fun and ProfitHacking Robots for Fun and Profit
Hacking Robots for Fun and Profit
 
Hacking Adobe Experience Manager sites
Hacking Adobe Experience Manager sitesHacking Adobe Experience Manager sites
Hacking Adobe Experience Manager sites
 
Доклад Михаила Егорова на PHDays
Доклад Михаила Егорова на PHDaysДоклад Михаила Егорова на PHDays
Доклад Михаила Егорова на PHDays
 

Recently uploaded

Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 

Recently uploaded (20)

Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 

Call for a better error handling in APIs

  • 1. Call for a better error handling in APIs
  • 2. André Cedik · Developer Advocate shipcloud.io · andre@shipcloud.io shipcloud GmbH · Mittelweg 162 20148 Hamburg
  • 3. API v2 • Incoporate learnings from more than 5 years • Easier integration in existing shop- / ERP-software • I18n • Returning translated strings • White label • Design first approach using OpenAPI
  • 4. But most of all ...
  • 5. ... better error communication!
  • 8. Mariner 1 • Veered off course, because unscheduled maneuver • Steering unpossible • Missing hyphen in the code allowed transmission of incorrect guidance signals • Engineers hit self destruct button • $18 million error
  • 9. ESA Ariane 5 Flight 501 • Reused software from Ariane 4 • Ariane 5 had faster engines • Software tried to push a 64-bit float into a signed 16- bit integer • Engineers hit self destruct button at 37 sec. into its maiden launch • $8 billion error
  • 10. NASA Mars Climate Orbiter • Failed conversion from imperial units to metric • Send the orbiter too close to Mars‘ surface • $125 million error
  • 11. Y2K Bug • Year numbers where saved with 2 digits (98,99,00,01) • No one knew what will happen when the year 2000 sets in • Since ‘00‘ also meant 1900 • $500 billion error
  • 12. Pentium-FDIV-Bug • In 1994 Math Prof. Thomas R. Nicely reported the bug • Processor might return incorrect binary floating point results when dividing a number • Intel attributed error to missing entries in the lookup table • Tried to downplay the bug • Had to replace processors • $475 million error
  • 14. Mokusatsu - The World‘s Most Tragic Translation • Allied leaders called for Japan’s unconditional surrender • Japanese government said nothing while considering their options • PM Kantaro Suzuki was pressured for comment • said only one word "mokusatsu“ • Mistranslation leads to the dropping of the atomic bomb
  • 15. Hawaii Missle Strike • In Jan. 2018 citizens of Hawaii were warned of an inbound ballistic missile strike • Turned out to be a false alert • Recording over phone „EXERCISE“ • Message with „THIS IS NOT A DRILL“ • Same UI used for drill and real alerts • No safeguards were in place • It took 38 minutes to retract the alert, because there was no response protocol for a false alert
  • 16. Error handling in APIs Tools used at the moment
  • 17. "Building fault-tolerant software boils down to detecting errors and doing something when errors are detected" Joe Armstrong, inventor of Erlang
  • 18. http response status codes • Informational 1xx • Successful 2xx • 200 OK • Redirection 3xx • 301 Moved Permanently • Client Error 4xx • Server Error 5xx
  • 19. http response status codes 4xx & 5xx • 400 Bad Request • 402 Payment Required • 403 Forbidden • 404 Not Found • 500 Internal Server Error • 502 Bad Gateway • 504 Gateway Timeout
  • 20. Error handling in the body • Good: • Return complex structures • Get more specific about an error • Convey multiple errors • Bad: • Everyone has their own way of doing it • Therefore developers have to understand „the way“
  • 21. Error handling in APIs The bad
  • 23. Sabre Dev Studio – error attribute • „error“ is always a string • Sometimes all Uppercase - > seems to be like an error code
  • 24. Sabre Dev Studio – error attribute • „error“ is always a string • Sometimes all Uppercase - > seems to be like an error code • Sometimes it looks like an error trace
  • 25. Sabre Dev Studio – code attribute • Sometimes it looks like a http response status code • Sometimes like an internal code • Same code used more than once • different error text • 102 • 111 • 404 • 500 • 700101 • 050002 • 060016 • 700202
  • 26. Sabre Dev Studio – code attribute
  • 27. Pitney Bowes • Each validated field has its own error code
  • 28. Pitney Bowes • Each validated field has its own error code • "XXX is invalid, unsupported or missing“ • So what is it now?!?
  • 29. Google Maps Geocoding API • Has a „status“ attribute • OK, ZERO_RESULTS, OVER_DAILY_LIMIT, OVER_QUERY_LIMIT, REQUEST_DENIED, INVALID_REQUEST, UNKNOWN_ERROR • INVALID_REQUEST = 400 Bad Request • OVER_QUERY_LIMIT = 200 OK
  • 33. Error handling in APIs The good parts
  • 40. What we can do better
  • 41. What‘s the problem? • „API calls either fail or are successful“ – Phil Sturgeon • „Soft errors“ • Not an exception type „crash“ • More like a warning
  • 42.
  • 43. application/problem+json • RFC 7807 • Pros • Own content type • Predefined set of attributes • Extensible • Cons • Not encapsulated • Mixing with other content • Multi error handling just for one error type HTTP/1.1 403 Forbidden Content-Type: application/problem+json Content-Language: en { "type": "https://example.com/probs/out-of-credit", "title": "You do not have enough credit.", "detail": "Your current balance is 30, but that costs 50.", "instance": "/account/12345/msgs/abc", "balance": 30, "accounts": ["/account/12345", "/account/67890"] }
  • 44. Warning header • RFC 7234 • Pros • You could handle „soft errors“ • Multiple warning header for multiple different errors • Cons • Complex data can‘t be returned • It‘s just a string HTTP/1.1 200 OK Date: Sat, 25 Aug 2012 23:34:45 GMT Warning: 112 - "network down" "Sat, 25 Aug 2012 23:34:45 GMT"
  • 45. application/health+json • Internet Draft inadarei-api- health-check • Pros • „status“ attribute („pass“, „warn“, „error“) • Cons • Specific to health of an api • Overhead content HTTP/1.1 200 OK Content-Type: application/health+json { "status": "pass", "version": "1", "releaseId": "1.2.2", "notes": [""], "output": "", "serviceId": "f03e522f-1f44-4062-9b55-9587f91c9c41", "description": "health of authz service", "checks": { "cassandra:responseTime": [ { "componentId": "dfd6cf2b-1b6e-4412-a0b8-f6f7797a60d2", "componentType": "datastore", "observedValue": 250, "observedUnit": "ms", "status": "pass", "affectedEndpoints" : [ "/users/{userId}", "/customers/{customerId}/status", "/shopping/{anything}" ], "time": "2018-01-17T03:36:48Z", "output": "" }
  • 46. application/vnd.api+json • JSON:API standard • Pros • Errors array to handle multiple errors • JSON pointers to show devs where an error has occurred • Cons • Everything is in errors object • „soft errors“ not possible
  • 47. Best current practice • HTTP status code • Error object • Easy referencing of errors • „Code“ • „Subcode“ • Request IDs in the body • for easier request identification in support cases • Human readable message • In multiple languages
  • 48. "An excellent error message is precise and lets the user know about the nature of the error so that they can figure their way out of it." Guy Levin, RestCase
  • 49. Future of error handling in APIs A proposal
  • 50. A proposal – to be discussed
  • 51. A proposal – to be discussed • Responses in a new format • „data“ holds everything we‘d normally have in the root • „errors“ and „warnings“ give information about what happened • „errors“ and „warnings“ follow the RFC 7807 pattern
  • 52. A proposal – to be discussed • „data“ is empty since no resource was created • Warnings possible if api supports this use case
  • 54. Sources • Atlas Agena with Mariner 1: NASA, https://commons.wikimedia.org/wiki/File:Atlas_Agena_with_Mariner_1.jpg • Ariane 5: DLR German Aerospace Center, https://www.flickr.com/photos/48213136@N06/8958839420 • Mars Climate Orbiter: NASA/JPL/Corby Waste, https://commons.wikimedia.org/wiki/File:Mars_Climate_Orbiter_2.jpg • Bug de l'an 2000: https://commons.wikimedia.org/wiki/File:Bug_de_l%27an_2000.jpg • Pentium: Konstantin Lanzet, https://commons.wikimedia.org/wiki/File:KL_Intel_Pentium_A80501.jpg • Hawaii Missle Alert SMS: https://twitter.com/tulsigabbard/status/952243723525677056