dosubot[bot] commented on issue #38811:
URL: https://github.com/apache/superset/issues/38811#issuecomment-4114121811

   <!-- Answer -->
   Thanks for the detailed bug report! I found the root cause.
   
   The issue is in 
[`formatValueHandler`](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/components/AlteredSliceTag/utils/index.ts#L46-L58)
 in the AlteredSliceTag component. The code formats filters like this:
   
   ```typescript
   return `${v.subject} ${v.operator} ${filterVal}`;
   ```
   
   For IS NULL and IS NOT NULL operators, the `comparator` is `undefined` by 
design since they're [unary 
operators](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/packages/superset-ui-core/src/query/types/Operator.ts#L21)
 that don't require a value. JavaScript coerces `undefined` to the string 
`"undefined"` in template literals, causing the display bug.
   
   **Fix**: The function should check for unary operators (IS NULL, IS NOT 
NULL, IS TRUE, IS FALSE) and skip appending the comparator. Something like:
   
   ```typescript
   const unaryOperators = ['IS NULL', 'IS NOT NULL', 'IS TRUE', 'IS FALSE'];
   if (unaryOperators.includes(v.operator)) {
     return `${v.subject} ${v.operator}`;
   }
   return `${v.subject} ${v.operator} ${filterVal}`;
   ```
   
   This would be a straightforward fix if you'd like to contribute a PR!
   
   
   <!-- Dosu Comment Footer -->
   *To reply, just mention 
[@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=brand-link).*
   
   ---
   <sup>How did I do? 
[Good](https://app.dosu.dev/response-feedback/8371f3d0-ce28-44ae-8f5e-3e7fb70830d9?feedback_type=great_response&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/8371f3d0-ce28-44ae-8f5e-3e7fb70830d9?feedback_type=irrelevant_answer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/8371f3d0-ce28-44ae-8f5e-3e7fb70830d9?feedback_type=incorrect_sources&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/8371f3d0-ce28-44ae-8f5e-3e7fb70830d9?feedback_type=too_verbose&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-too_verbose)
 | [Hallucination](https://app.dosu.dev/response-feedback/8371f3d0-ce28
 
-44ae-8f5e-3e7fb70830d9?feedback_type=hallucination&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/8371f3d0-ce28-44ae-8f5e-3e7fb70830d9?feedback_type=bug_report&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/8371f3d0-ce28-44ae-8f5e-3e7fb70830d9?feedback_type=other&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-other)</sup>
   
   [![Chat with 
Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=chat-badge)&nbsp;[![Open
 in 
Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=Thanks%20for%20the%20detailed%20bug%20report%21%20I%20found%20the%20root%20cause.%0A%0AThe%20issue%20is%20in%20%5B%60formatValueHandler%60%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/components/AlteredSliceTag/utils/index.ts%23L46-L58%29%20in%20the%20AlteredSliceTag%20component.%20The%20code%20formats%20filters%20like%20this%3A%0A%0A%60%60%60typescript%0Areturn%20%60%24%7Bv.subject%7D%20%24%7Bv.operator%7D%20%24%7BfilterVal%7D%60%3B%0A%60%60%60%0A%0AFor%20IS%20NULL%20and%20IS%20NOT%20NULL%20operators%2C%20the%20%60comparator%60%20is%20%60undefined%60%20by%20design%20since%20they%27re%20%5Bunary%20operators%5D
 
%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/packages/superset-ui-core/src/query/types/Operator.ts%23L21%29%20that%20don%27t%20require%20a%20value.%20JavaScript%20coerces%20%60undefined%60%20to%20the%20string%20%60%22undefined%22%60%20in%20template%20literals%2C%20causing%20the%20display%20bug.%0A%0A%2A%2AFix%2A%2A%3A%20The%20function%20should%20check%20for%20unary%20operators%20%28IS%20NULL%2C%20IS%20NOT%20NULL%2C%20IS%20TRUE%2C%20IS%20FALSE%29%20and%20skip%20appending%20the%20comparator.%20Something%20like%3A%0A%0A%60%60%60typescript%0Aconst%20unaryOperators%20%3D%20%5B%27IS%20NULL%27%2C%20%27IS%20NOT%20NULL%27%2C%20%27IS%20TRUE%27%2C%20%27IS%20FALSE%27%5D%3B%0Aif%20%28unaryOperators.includes%28v.operator%29%29%20%7B%0A%20%20return%20%60%24%7Bv.subject%7D%20%24%7Bv.operator%7D%60%3B%0A%7D%0Areturn%20%60%24%7Bv.subject%7D%20%24%7Bv.operator%7D%20%24%7BfilterVal%7D%60%3B%0A%60%60%60%0A%0AThis%20would%20be%20a%20straightforwa
 rd%20fix%20if%20you%27d%20like%20to%20contribute%20a%20PR%21)&nbsp;[![Join 
Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=join-discord)&nbsp;[![Share
 on 
X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/issues/38811)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to