{"record":{"id":"22e2ef49dd78c84b","repo":"mvanhorn/last30days-skill","slug":"polymarket-item-has-no-event-id-or-slug","errorCode":null,"errorMessage":"Polymarket item has no event id or slug","messagePattern":"Polymarket item has no event id or slug","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"skills/last30days/scripts/lib/polymarket.py","lineNumber":959,"sourceCode":"        payload = http.request(\n            \"GET\", f\"{GAMMA_EVENTS_URL}/{quote(event_id)}\", timeout=10, retries=2,\n        )\n    elif slug_match:\n        if not expected_id:\n            # No event id anywhere: slug equality alone cannot verify event\n            # identity, so fail closed (unsupported) instead of re-deriving a\n            # verdict from whatever event currently owns the slug.\n            raise ValueError(\n                \"Polymarket item carries no event id; slug equality alone \"\n                \"cannot verify event identity\"\n            )\n        requested_slug = slug_match.group(1)\n        payload = http.request(\n            \"GET\", GAMMA_EVENTS_URL, params={\"slug\": requested_slug},\n            timeout=10, retries=2,\n        )\n    else:\n        raise ValueError(\"Polymarket item has no event id or slug\")\n\n    requested_slug = slug_match.group(1) if slug_match else None\n\n    def _matches_identity(entry: dict) -> bool:\n        if str(entry.get(\"slug\") or \"\").strip() != requested_slug:\n            return False\n        if expected_id and str(entry.get(\"id\") or \"\").strip() != expected_id:\n            return False\n        return True\n\n    def _pick_event(events: list) -> Any:\n        candidates = [entry for entry in events if isinstance(entry, dict)]\n        if requested_slug is None:\n            return candidates[0] if candidates else None\n        # Verify identity: Gamma slug queries can return multiple or loosely\n        # matched events, and verifying a claim against another market's\n        # prices would fabricate current/stale verdicts.\n        for entry in candidates:","sourceCodeStart":941,"sourceCodeEnd":977,"githubUrl":"https://github.com/mvanhorn/last30days-skill/blob/c7460f6114449ddfe6ea3fc2f23c3d910c0e740c/skills/last30days/scripts/lib/polymarket.py#L941-L977","documentation":"ValueError raised in Polymarket refetch when the item provides neither a derivable event id nor a slug to query - there is no way to locate the event on the Gamma API at all. This is a hard data-quality failure distinct from the slug-without-id case (error 81), which deliberately fails closed for identity reasons.","triggerScenarios":"refetch_datum receives an item whose url does not match the event slug regex (or is empty) and from which no numeric event id could be extracted. Both the event_id and slug_match branches are skipped, falling into the final else raise.","commonSituations":"Corrupted or truncated URLs in persisted items; items built from non-event Polymarket pages (markets, leaderboards) routed into the event refetch path; URL parsing changes after a Polymarket site redesign.","solutions":["Validate that item.url matches a polymarket.com/event/... pattern before calling refetch_datum","Re-ingest the item through the search pipeline to rebuild a well-formed URL and metadata","Catch ValueError and drop/quarantine the malformed item instead of re-fetching"],"exampleFix":"# before\ndatum = refetch_datum(item, \"Yes\")  # item.url is ''\n\n# after\nimport re\nif not re.search(r\"polymarket\\.com/event/\", item.url or \"\"):\n    skip_item(item)\nelse:\n    datum = refetch_datum(item, \"Yes\")","handlingStrategy":"validation","validationCode":"import re\n\ndef has_polymarket_locator(item) -> bool:\n    url = getattr(item, \"url\", \"\") or \"\"\n    return bool(re.search(r\"polymarket\\.com/event/([\\w-]+)\", url)) or bool(\n        getattr(item, \"id\", None) and re.fullmatch(r\"\\d+\", str(item.id))\n    )","typeGuard":null,"tryCatchPattern":"try:\n    datum = refetch_datum(item, key)\nexcept ValueError as e:\n    if \"no event id or slug\" in str(e):\n        quarantine(item)  # malformed locator; re-ingest needed\n    raise","preventionTips":["Validate item.url matches the /event/ pattern before scheduling re-verification","Rebuild items through search_polymarket rather than hand-constructing them","Quarantine items with empty URLs at ingest"],"tags":["polymarket","data-quality","validation","valueerror"],"backgroundTag":null,"analyzedSha":"c7460f6114449ddfe6ea3fc2f23c3d910c0e740c","analyzedAt":"2026-08-15T03:34:49.540Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}