{"record":{"id":"5f4c5d3110704658","repo":"langgenius/dify","slug":"has-comment-must-be-a-boolean-value","errorCode":null,"errorMessage":"has_comment must be a boolean value","messagePattern":"has_comment must be a boolean value","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"api/controllers/console/app/message.py","lineNumber":108,"sourceCode":"class FeedbackExportQuery(BaseModel):\n    from_source: Literal[\"user\", \"admin\"] | None = Field(default=None, description=\"Filter by feedback source\")\n    rating: Literal[\"like\", \"dislike\"] | None = Field(default=None, description=\"Filter by rating\")\n    has_comment: bool | None = Field(default=None, description=\"Only include feedback with comments\")\n    start_date: str | None = Field(default=None, description=\"Start date (YYYY-MM-DD)\")\n    end_date: str | None = Field(default=None, description=\"End date (YYYY-MM-DD)\")\n    format: Literal[\"csv\", \"json\"] = Field(default=\"csv\", description=\"Export format\")\n\n    @field_validator(\"has_comment\", mode=\"before\")\n    @classmethod\n    def parse_bool(cls, value: bool | str | None) -> bool | None:\n        if isinstance(value, bool) or value is None:\n            return value\n        lowered = value.lower()\n        if lowered in {\"true\", \"1\", \"yes\", \"on\"}:\n            return True\n        if lowered in {\"false\", \"0\", \"no\", \"off\"}:\n            return False\n        raise ValueError(\"has_comment must be a boolean value\")\n\n\nclass AnnotationCountResponse(ResponseModel):\n    count: int = Field(description=\"Number of annotations\")\n\n\nclass SuggestedQuestionsResponse(ResponseModel):\n    data: list[str] = Field(description=\"Suggested question\")\n\n\nclass MessageDetailResponse(BaseMessageDetailResponse):\n    extra_contents: list[ExecutionExtraContentDomainModel] = Field(default_factory=list)\n\n\nclass MessageInfiniteScrollPaginationResponse(ResponseModel):\n    limit: int\n    has_more: bool\n    data: list[MessageDetailResponse]","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/controllers/console/app/message.py#L90-L126","documentation":"ValueError raised by the field_validator on FeedbackExportQuery.has_comment (message.py:108) when the incoming value is a string that is not a recognized boolean token. The validator accepts actual bools, None, and the strings 'true/1/yes/on' (true) and 'false/0/no/off' (false), case-insensitively; anything else is rejected and surfaced by Pydantic as a 422/400.","triggerScenarios":"GET /console/api/apps/<app_id>/message/feedback/export with a has_comment query param whose value is not a recognized boolean string (e.g. has_comment=maybe, has_comment=y, has_comment=2).","commonSituations":"Client using shorthand like 'y'/'n' or 't'/'f'; copy-pasted URL with a wrong value; localization producing non-English words.","solutions":["Send has_comment as a standard boolean string: 'true'/'false', '1'/'0', 'yes'/'no', or 'on'/'off'.","Omit the param entirely if you do not want to filter by comment presence.","If your client only emits 'y'/'n', preprocess to 'true'/'false' before calling."],"exampleFix":"// before\nGET /message/feedback/export?has_comment=maybe\n// after\nGET /message/feedback/export?has_comment=true","handlingStrategy":"validation","validationCode":"const TRUTHY = new Set(['true', '1', 'yes', 'on']);\nconst FALSY = new Set(['false', '0', 'no', 'off']);\nfunction normalizeHasComment(v: string | boolean | null): boolean | null {\n  if (v === null || typeof v === 'boolean') return v;\n  const l = String(v).toLowerCase();\n  if (TRUTHY.has(l)) return true;\n  if (FALSY.has(l)) return false;\n  throw new Error(`has_comment must be one of true|false|1|0|yes|no|on|off, got ${v}`);\n}","typeGuard":"function isAcceptedBoolString(v: string): boolean {\n  const l = v.toLowerCase();\n  return ['true','1','yes','on','false','0','no','off'].includes(l);\n}","tryCatchPattern":null,"preventionTips":["Send has_comment as a literal boolean (true/false) rather than a string when possible.","Avoid shorthand like 'y'/'n'; expand to 'yes'/'no' before calling.","If unsure, omit the param entirely."],"tags":["validation","boolean","query-param","feedback-export","pydantic"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}