{"record":{"id":"e4d88b3cd66e0916","repo":"projectlombok/lombok","slug":"expected-a-span-with-id-currentversion","errorCode":null,"errorMessage":"Expected a span with id 'currentVersion'","messagePattern":"Expected a span with id 'currentVersion'","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"src/support/lombok/website/FetchCurrentVersion.java","lineNumber":28,"sourceCode":"public class FetchCurrentVersion {\n\tprivate FetchCurrentVersion() {}\n\t\n\tprivate static final Pattern VERSION_PATTERN = Pattern.compile(\"^.*<\\\\s*span\\\\s+id\\\\s*=\\\\s*[\\\"'](currentVersion|currentVersionFull)[\\\"'](?:\\\\s+style\\\\s*=\\\\s*[\\\"']display\\\\s*:\\\\s*none;?[\\\"'])?\\\\s*>\\\\s*([^\\t<]+)\\\\s*<\\\\s*/\\\\s*span\\\\s*>.*$\");\n\t\n\tpublic static void main(String[] args) throws IOException {\n\t\tSystem.out.print(fetchVersionFromSite(args.length < 2 || args[1].equals(\"full\"), new Domain(args.length < 1 ? \"\" : args[0])));\n\t}\n\t\n\tpublic static String fetchVersionFromSite(boolean fetchFull, Domain domain) throws IOException {\n\t\tInputStream in = domain.url(\"download\").openStream();\n\t\ttry {\n\t\t\tBufferedReader br = new BufferedReader(new InputStreamReader(in, \"UTF-8\"));\n\t\t\ttry {\n\t\t\t\tfor (String line = br.readLine(); line != null; line = br.readLine()) {\n\t\t\t\t\tMatcher m = VERSION_PATTERN.matcher(line);\n\t\t\t\t\tif (m.matches() && m.group(1).equals(\"currentVersionFull\") == fetchFull) return m.group(2).replace(\"&quot;\", \"\\\"\");\n\t\t\t\t}\n\t\t\t\tthrow new IOException(\"Expected a span with id 'currentVersion'\");\n\t\t\t} finally {\n\t\t\t\tbr.close();\n\t\t\t}\n\t\t} finally {\n\t\t\tin.close();\n\t\t}\n\t}\n}\n","sourceCodeStart":10,"sourceCodeEnd":37,"githubUrl":"https://github.com/projectlombok/lombok/blob/6d6a3e9fec0a9555702561fbeb8eac836575116e/src/support/lombok/website/FetchCurrentVersion.java#L10-L37","documentation":"FetchCurrentVersion.fetchVersionFromSite downloads a project web page and scans each line against VERSION_PATTERN looking for a span whose id is 'currentVersion' (or 'currentVersionFull' when fetchFull). If no line matches (or the id doesn't correspond to the requested variant), it throws this IOException. It means the fetched page did not contain the expected version marker.","triggerScenarios":"main -> fetchVersionFromSite against the project website when the HTML changed (span id renamed/removed), a CDN/error/consent page is returned instead of the real site, the wrong variant is requested (fetchFull=true but page only shows 'currentVersion'), or the URL points to a page that never carries the marker.","commonSituations":"Website redesign changes the span id; project.eclipse.org serves a maintenance/error page; mirroring a page that only contains currentVersionFull (or vice versa); network middleboxes (captive portal) inject HTML.","solutions":["Inspect the HTML actually fetched (curl the URL) and confirm whether a span with id 'currentVersion' (or 'currentVersionFull') exists.","Check you are hitting the live site, not an error/redirect/consent page — resolve redirects or update the URL in the script.","If the site markup changed, update VERSION_PATTERN or the span id in FetchCurrentVersion to match the new HTML.","Match the fetchFull flag to the marker actually present: fetchFull=true requires 'currentVersionFull'."],"exampleFix":"// before (page changed id)\n<span id=\"latestVersion\">1.18.30</span>  -> IOException(\"Expected a span with id 'currentVersion'\")\n// after (update pattern/expected id in code)\nMatcher m = Pattern.compile(\".*id=.(currentVersionFull|latestVersion).*?>(((\\\\d+)\\\\.(\\\\d+))).*\").matcher(line);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    String v = fetchVersionFromSite(url, fetchFull);\n} catch (IOException e) {\n    if (\"Expected a span with id 'currentVersion'\".equals(e.getMessage())) {\n        // dump fetched HTML, check for redirect/error page or changed span id\n        String html = slurp(url);\n        if (!html.contains(\"currentVersion\")) throw new IllegalStateException(\"Page no longer contains version marker; update VERSION_PATTERN\", e);\n    } else throw e;\n}","preventionTips":["Preflight: curl the URL and confirm the span id 'currentVersion'/'currentVersionFull' is present before running.","Handle redirects and CDN error pages — detect non-200 or unexpected HTML early.","Match fetchFull to the marker present on the page ('currentVersionFull' when fetchFull).","Monitor website markup changes and update VERSION_PATTERN promptly."],"tags":["html-scraping","network","website","java"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"6d6a3e9fec0a9555702561fbeb8eac836575116e","analyzedAt":"2026-09-07T23:18:01.841Z","contentChangedAt":"2026-09-07T23:18:01.841Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}