These errors are special as they indicate that (as I understand) fault is on osm side and it should be retried, though ideally with some delay (as these seem to happen more often when OSM servers are overloaded)
example seen in my logs follows
note that these are not easily triggered or reproducible
osmapi.errors.ApiError: Request failed: 500 - Internal Server Error - b'<!DOCTYPE html>\n<html lang="en" dir="ltr">\n <head>\n <meta charset="utf-8">\n <title>OpenStreetMap</title>\n <link rel="stylesheet" href="/assets/errors-64b64cdaf29dd860705f7aa56fbb380db82bfa6ca7c6723065b28d21ba7548ce.css" media="screen" />\n \n<meta http-equiv="X-UA-Compatible" content="IE=edge">\n<meta name="viewport" content="width=device-width, initial-scale=1">\n<link rel="apple-touch-icon" type="image/png" href="/assets/apple-touch-icon-57x57-0af2b52ac2b1a8cb0aba42f17aa901bfdedb9174bd978f838e3b3e1dd8602f52.png" sizes="57x57" />\n<link rel="apple-touch-icon" type="image/png" href="/assets/apple-touch-icon-60x60-cff74c9066d8e7fd08b29407712edbae5613cc9a4c03ee0398a89502a6a41d1f.png" sizes="60x60" />\n<link rel="apple-touch-icon" type="image/png" href="/assets/apple-touch-icon-72x72-63c6fdf3ddf65feebac1c0441bf6a378d1e4bde7107f598ae86733c402895eae.png" sizes="72x72" />\n<link rel="apple-touch-icon" type="image/png" href="/assets/apple-touch-icon-76x76-1740d6e7a59521693c496dd8fbe1caf3d5ad302017cb0f5073b6914b4f5b7544.png" sizes="76x76" />\n<link rel="apple-touch-icon" type="image/png" href="/assets/apple-touch-icon-114x114-20ba9df1a8f9b341040d661b7942b7b10288b9b4c4ce0663e10018958dc7f4a8.png" sizes="114x114" />\n<link rel="apple-touch-icon" type="image/png" href="/assets/apple-touch-icon-120x120-c304991e604d1be82639709b96fb87f7b6b6688cc0d04d5f6141604259299648.png" sizes="120x120" />\n<link rel="apple-touch-icon" type="image/png" href="/assets/apple-touch-icon-144x144-fbf20bdf9d2f7c1fe8eb85d7869a9bda285be88c93a39438150f5eb5955758ce.png" sizes="144x144" />\n<link rel="apple-touch-icon" type="image/png" href="/assets/apple-touch-icon-152x152-af45dc979e972cab863517b2cb33a3dcf3e04e02a2eb2734c6f93edc21fa395d.png" sizes="152x152" />\n<link rel="apple-touch-icon" type="image/png" href="/assets/apple-touch-icon-180x180-ea6361d7ae5b3f08c6290652ad703fa239364cc09c84873044f3299845f24652.png" sizes="180x180" />\n<link rel="icon" type="image/png" href="/assets/favicon-32x32-99b88fcadeef736889823c8a886b89d8cada9d4423a49a27de29bacc0a6bebd1.png" sizes="32x32" />\n<link rel="icon" type="image/png" href="/assets/favicon-194x194-79d3fb0152c735866e64b1d7535d504483cd13c2fad0131a6142bd9629d30de2.png" sizes="194x194" />\n<link rel="icon" type="image/png" href="/assets/favicon-96x96-6ffbc38962fddb870f9577b76430a0ee4db5fb4eca485f850cd45436d7f3eb87.png" sizes="96x96" />\n<link rel="icon" type="image/png" href="/assets/android-chrome-192x192-f970b9be3965dfda6ea9481b305c39b2ec794e296f802235e30d4671f0f896e1.png" sizes="192x192" />\n<link rel="icon" type="image/png" href="/assets/favicon-16x16-474476c1b2381628a81361a9e2bf04b936d21f77c59e84b48c6c69ea376fb6cf.png" sizes="16x16" />\n<link rel="mask-icon" href="/assets/tab-icon-07d8c4247610d2f043ac298b3905536230b9615b08e23e69026c8d55790da13b.svg" color="#7ebc6f">\n<link rel="manifest" href="/assets/manifest-97cb57bafa7f7f002cc5fe5532b856c4246eef5cbbd21c78b4c6bc2ffa46747a.json">\n<meta name="msapplication-config" content="/assets/browserconfig-c59184dc0264731151cbf50ae58f7fa8ae5153138013f125203e1193800f862f.xml">\n<meta name="msapplication-TileColor" content="#00a300">\n<meta name="msapplication-TileImage" content="/assets/mstile-144x144-02723f6f7cb2c18e6f8041c93f80982decb52b24a7e447477bc2ce3136d75806.png">\n<meta name="theme-color" content="#ffffff">\n<meta name="turbo-refresh-method" content="morph">\n<meta name="turbo-refresh-scroll" content="preserve">\n<link href="https://www.openstreetmap.org/500" rel="canonical" />\n<link rel="search" type="application/opensearchdescription+xml" title="OpenStreetMap Search" href="/assets/osm-42b7b3fbcee2193e455a773db6cd3d34a2f48ca94547fed54901dd9d8307b02b.xml">\n<meta name="description" content="OpenStreetMap is a map of the world, created by people like you and free to use under an open license.">\n<meta property="og:site_name" content="OpenStreetMap">\n<meta property="og:title" content="OpenStreetMap">\n<meta property="og:type" content="website">\n<meta property="og:url" content="https://www.openstreetmap.org/500">\n<meta property="og:description" content="OpenStreetMap is a map of the world, created by people like you and free to use under an open license.">\n<meta property="og:image" content="https://www.openstreetmap.org/assets/osm_logo_256-ed028f90468224a272961c380ecee0cfb73b8048b34f4b4b204b7f0d1097875d.png">\n<meta property="og:image:alt" content="OpenStreetMap logo">\n\n </head>\n <body>\n <main>\n <a href="/" class="logo">\n <img alt="OpenStreetMap logo" src="/assets/osm_logo-cc7d94392992162133be3baa21a37eb84f19f9b91178f704005378fbeecabb4e.svg" />\n </a>\n <div class="details">\n <h1>Application error</h1>\n<p>The OpenStreetMap server encountered an unexpected condition that prevented it from fulfilling the request (HTTP 500)</p>\n\n<p>Feel free to <a title="Various contact channels explained" href="https://wiki.openstreetmap.org/wiki/Contact">contact</a> the OpenStreetMap community if you have found a broken link / bug. Make a note of the exact URL of your request.</p>\n\n\n </div>\n </main>\n </body>\n</html>'
These errors are special as they indicate that (as I understand) fault is on osm side and it should be retried, though ideally with some delay (as these seem to happen more often when OSM servers are overloaded)
example seen in my logs follows
note that these are not easily triggered or reproducible