The following behaviors do not make a custom entity flee the sun as they should:
"minecraft:behavior.flee_sun" {}
"minecraft:behavior.restrict_sun" {}
The custom entity does not flee the sun in any situation unless they are assigned a runtime identifier of an entity that flees the sun, like a skeleton.
Steps to reproduce:
1. Import the attached pack and apply it to a new creative mode world.
2. Make a solid block ceiling.
3. Spawn a pig under the open sky, near the ceiling.
Expected result
The pig moves under the solid blocks.
Observed result
The pig does not flee the sun, no matter what their priority is or if the sun is burning them.
Linked issues
Attachments
Comments 3

I created a pack to test the issue and found that the avoid_sun parameter inside navigation.walk does work, so I removed that from the description. Also updated the steps to use with the pack.
The pig file in the pack contains "avoid_sun": true,
You can confirm that this parameter works by spawning a pig under a small, solid roof. It will not come out from under the roof even if you tempt it with food.