# Representation of invalid HdSceneIndexPrim

**URL:** <https://forum.aousd.org/t/representation-of-invalid-hdsceneindexprim/833>\
**Category:** Hydra\
**Created:** [October 20, 2023, 3:18pm UTC](https://forum.aousd.org/t/representation-of-invalid-hdsceneindexprim/833 "2023-10-20T15:18:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ppt-adsk](https://avatars.discourse-cdn.com/v4/letter/p/f4b2a3/32.png) [@ppt-adsk](https://forum.aousd.org/u/ppt-adsk)\
**Post date:** [October 20, 2023, 3:18pm UTC](https://forum.aousd.org/t/representation-of-invalid-hdsceneindexprim/833/1 "2023-10-20T15:18:34Z")

</div>

It is often very convenient to have a concept of an invalid object, to represent error conditions or invalid queries. An invalid HdSceneIndexPrim

> <https://github.com/PixarAnimationStudios/OpenUSD/blob/10b62439e9242a55101cf8b200f2c7e02420e1b0/pxr/imaging/hd/sceneIndex.h#L51>

seems to be one that has a null data source, as demonstrated here:

> <https://github.com/PixarAnimationStudios/OpenUSD/blob/10b62439e9242a55101cf8b200f2c7e02420e1b0/pxr/imaging/hd/mergingSceneIndex.cpp#L217>

It appears that it is legal for the prim type to be empty for a valid prim, which is then a typeless prim. Only the dataSource data member determines an invalid prim, when it is null. Is this interpretation correct?

My uncertainty is based on the fact that a retained scene index uses an SdfPathTable to store prims:

> <https://github.com/PixarAnimationStudios/OpenUSD/blob/10b62439e9242a55101cf8b200f2c7e02420e1b0/pxr/imaging/hd/retainedSceneIndex.h#L107>

And SdfPathTable inserts missing ancestors on inserting a prim:

> <https://github.com/PixarAnimationStudios/OpenUSD/blob/10b62439e9242a55101cf8b200f2c7e02420e1b0/pxr/usd/sdf/pathTable.h#L53>

However, inserted ancestors are inserted with the default mapped type:

> <https://github.com/PixarAnimationStudios/OpenUSD/blob/10b62439e9242a55101cf8b200f2c7e02420e1b0/pxr/usd/sdf/pathTable.h#L722>

which for HdSceneIndexPrim is a prim with a null data source.

Therefore, a retained scene index can return prims that have a null data source. Hopefully someone can explain what appears to me to be a discrepancy. Thanks for any help!

Pierre

---

<div class="post-metadata">

**Author:** ![tomc](https://avatars.discourse-cdn.com/v4/letter/t/8dc957/32.png) [@tomc](https://forum.aousd.org/u/tomc)\
**Post date:** [November 18, 2023, 12:36am UTC](https://forum.aousd.org/t/representation-of-invalid-hdsceneindexprim/833/2 "2023-11-18T00:36:10Z")

</div>

You’re correct that we do have typeless prims with data. I think sometimes we have typeless prims without data (but which have a path, and might later get data), and currently those are represented by a null datasource; I don’t think that’s semantically a problem, although it requires a null check before you refer to the datasource. Does that all make sense?

I guess if we wanted an invalid value with a null datasource, we could have the default constructor refer to a static empty container datasource.
