{"record":{"id":"120be9f36c8491c7","repo":"pathwaycom/pathway","slug":"duplicate-example-id-id","errorCode":null,"errorMessage":"Duplicate example id: {id}","messagePattern":"Duplicate example id: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/pathway/io/http/_server.py","lineNumber":118,"sourceCode":"    def add_example(self, id, summary, values):\n        \"\"\"\n        Adds an example to the collection.\n\n        Args:\n            id: Short and unique ID for the example. It is used for naming the example\n                within the Open API schema. By using ``default`` as an ID, you can set the example\n                default for the readers, while users will be able to select another ones via the\n                dropdown menu.\n            summary: Human-readable summary of the example, describing what is shown.\n                It is shown in the automatically generated dropdown menu.\n            values: The key-value dictionary, a mapping from the fields described in\n                schema to their values in the example.\n\n        Returns:\n            EndpointExamples: The current instance, allowing method chaining.\n        \"\"\"\n        if id in self.examples_by_id:\n            raise ValueError(f\"Duplicate example id: {id}\")\n        self.examples_by_id[id] = {\n            \"summary\": summary,\n            \"value\": values,\n        }\n        return self\n\n    def _openapi_description(self):\n        return self.examples_by_id\n\n\nclass EndpointDocumentation:\n    \"\"\"\n    The settings for the automatic OpenAPI v3 docs generation for an endpoint.\n\n    Args:\n        summary: Short endpoint description shown as a hint in the endpoints list.\n        description: Comprehensive description for the endpoint.\n        tags: Tags for grouping the endpoints.","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/io/http/_server.py#L100-L136","documentation":"Raised by EndpointExamples.add_example (the fluent API for documenting HTTP endpoint examples) when the same example id is registered twice. Example ids must be unique within one endpoint because they key the OpenAPI examples map and the request-body dropdown in the generated docs UI.","triggerScenarios":"Calling http_endpoint(...).request(...).add_example(id=\"default\", ...) twice, or adding examples in a loop where the same id (commonly \"default\") is reused for different values.","commonSituations":"Registering a fallback example with id=\"default\" after already adding a default; generating examples from a dict where keys repeat; merging example sets from multiple config sources without id collision checks.","solutions":["Give each example a distinct id: add_example(id=\"minimal\", ...), add_example(id=\"full\", ...).","When overriding a previously added example, replace it deliberately: del endpoint.examples.examples_by_id[\"default\"] before re-adding, or overwrite the dict entry directly.","Deduplicate ids before a loop: assert len(ids) == len(set(ids))."],"exampleFix":"# before\nex.add_example(id=\"default\", summary=\"basic\", values={...})\nex.add_example(id=\"default\", summary=\"other\", values={...})  # ValueError\n\n# after\nex.add_example(id=\"basic\", summary=\"basic\", values={...})\nex.add_example(id=\"advanced\", summary=\"other\", values={...})","handlingStrategy":"validation","validationCode":"if example_id in endpoint.examples.examples_by_id:\n    raise ValueError(f\"example id {example_id!r} already registered\")\nendpoint.examples.add_example(id=example_id, summary=summary, values=values)","typeGuard":null,"tryCatchPattern":"try:\n    docs.add_example(id=example_id, summary=summary, values=values)\nexcept ValueError as e:\n    if \"Duplicate example id\" in str(e):\n        docs.examples_by_id.pop(example_id, None)  # or overwrite entry directly\n        docs.add_example(id=example_id, summary=summary, values=values)\n    else:\n        raise","preventionTips":["Reserve id=\"default\" for exactly one example per endpoint.","Generate ids from stable slugs when adding examples in loops."],"tags":["http","openapi","examples","api-misuse"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}