AEM 6.5 Navigation Core Component throws Sigthly Exception Operands are not of the same type: comparison is supported for Number types only. | Community
Skip to main content
Level 2
February 19, 2023
Solved

AEM 6.5 Navigation Core Component throws Sigthly Exception Operands are not of the same type: comparison is supported for Number types only.

  • February 19, 2023
  • 4 replies
  • 1307 views

I have to display the navigation items based on user entity tags. So i have decided to extend the Core component Navigation model and  filter those results. 

But i get this error with the core Navigation component. I believe the error is in the below line

data-sly-test.hascontent="${navigation.items.size > 0}"

 

Any suggestions or fixes?

 

Stacktrace:

 

Caused by: org.apache.sling.scripting.sightly.compiler.SightlyCompilerException: Operands are not of the same type: comparison is supported for Number types only.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Jagadeesh_Prakash

@archr 

Below code should not be the issue. But check if navidation.items.size is returning numeric 

data-sly-test.hascontent="${navigation.items.size > 0}" 

 

And also check your Sightly script for any comparisons being made between non-numeric values, such as strings or booleans. You should ensure that both operands are numeric values before attempting to compare them.

 

If you are comparing variables or properties, you should also make sure that their values are being correctly assigned and are of the expected type. You may need to explicitly cast or convert the values to the correct type before making the comparison.

4 replies

bilal_ahmad
Level 5
February 19, 2023

Hi,
The Sightly block statement you shared

data-sly-test.hasContent="${navigation.items.size > 0}"

 should not throw any error ideally because it is a part of navigation.html.

can you share the complete stack trace? and if possible share a few more details as in if how you've customized it.

Ritesh_Mittal
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
February 20, 2023

Hi @archr ,

 

The issue must be with the extended model. You need to debug the Sling Model and check if while filtering the items are coming zero or some other unexpected behavior. Just check the size of items in Sling Model while debugging.

 

Thanks,

Ritesh Mittal

rampai
Community Advisor
Community Advisor
February 20, 2023

Hi @archr ,

 

Looks like, the error is in code, at a location where "Less or equal" comparison is happening as the error below mentions LEQ and not GT (greater than) binary operator.

 

at org.apache.sling.scripting.sightly.compiler.expression.nodes.BinaryOperator.leq(BinaryOperator.java:214) [org.apache.sling.scripting.sightly.compiler:1.1.2.1_4_0]

 

Do you happen to have any "<=" comparisons in your extended code?

 

Thanks,

Ram

Jagadeesh_Prakash
Community Advisor
Jagadeesh_PrakashCommunity AdvisorAccepted solution
Community Advisor
February 20, 2023

@archr 

Below code should not be the issue. But check if navidation.items.size is returning numeric 

data-sly-test.hascontent="${navigation.items.size > 0}" 

 

And also check your Sightly script for any comparisons being made between non-numeric values, such as strings or booleans. You should ensure that both operands are numeric values before attempting to compare them.

 

If you are comparing variables or properties, you should also make sure that their values are being correctly assigned and are of the expected type. You may need to explicitly cast or convert the values to the correct type before making the comparison.