CapsuleCast not hitting Mesh colliders in narrow scenarios

In the process of building a kinematic player controller, I’ve run into a number of clipping issues with certain configurations of geometry. I assumed I’d be able to tackle these one by one as I refined it, but the most stubborn and unpredictable by far seemed to arise in very geometrically simple setups, mostly around the bare edges and outwards corners of Mesh colliders. After stripping down the process to almost nothing and having it still clip surfaces, I investigated CapsuleCast itself and found that it either has some edge failures or something major is eluding me.

This is one configuration that I’ve been able to replicate the results with, where a default sized capsule is being cast directly downwards (I’ve ensured that the cast does not start within the collider already):

Vector3 castpos = transform.position;
Vector3 p1 = castpos + up_direction * 0.5f; //up_direction = Vector3.up
Vector3 p2 = p1 - up_direction;
Physics.CapsuleCast(p1, p2, 0.5f, -up_direction, out RaycastHit hit, 2f);

Intuitively this should collide without much margin at all but it is simply not reported using CapsuleCast. Using CheckCapsule at the start shows it’s clear, and the end obstructed. Moving it ever so slightly in any direction laterally works just fine, but here it’s in this narrow area where it can’t hit irregardless of the vertical position. I tested the same setup using a box collider and couldn’t get anything like this to happen, so I’m assuming it has something to do with Mesh colliders, but since I can’t find anything related to this online I figure I must just be missing something (which I’m hoping is the case since all my attempts at fudging the inputs have resulted in undesirable behavior.) Thanks

i also am coding a character controller from scratch and i have this issue capsule cast and hitting mesh colliders on specific edges in specific situations.
I found out that making the mesh convex will fix this, but obviously i cant just make everything convex so im also looking for a solution here

(i didnt want to make a new message but it doesnt seem you can modify old messages)

So i think i found a solution (if youre making a controller),
Instead of touching the capsule cast function, i instead implemented a depenetration function after the cast using Physics. ComputePenetration, really easy and quick solution, just use this function to move the player controller by the dir and distance the function produces.
Now i dont fall anymore through those edgecases where the capsule cast would straight up fail and ignore the geometry.
This still has the chance to fail if the capsulecast failure happens while going really fast i guess, but imo this reduces the probability of error to negligeable so for the moment i call it fixed.

void Depenetration()
        {
            Vector3 capsuleHalf = transform.up * (charCollider.height * 0.5f - charCollider.radius);

            Vector3 capsulePoint1 = transform.position + capsuleHalf;
            Vector3 capsulePoint2 = transform.position - capsuleHalf;

            Collider[] colliders = new Collider[1]; //i just store the first collider instead of multiple, work just fine for me this way
            int hits = Physics.OverlapCapsuleNonAlloc(capsulePoint1, capsulePoint2, charCollider.radius - skinOffset, colliders, validGround);
            if (hits > 0)
            {
                Physics.ComputePenetration(charCollider, charCollider.transform.position, charCollider.transform.rotation, colliders[0], colliders[0].transform.position, colliders[0].transform.rotation, out Vector3 dir, out float dist);

                transform.position += dir * dist;
            }
        }