Select to view content in your preferred language

ItemGraph Nodes of NoneType Items: How do I identify these programmatically?

207
2
Monday
Labels (3)
ODWC_GIS
Frequent Contributor

I have successfully created an ItemGraph of my AGOL Organization.  It is updated nightly.  (Thanks to this notebook, and community feedback.)

I have been trying to Navigate the resultant ItemGraph with varying degrees of success.

I also have a List of AGOL Item IDs from another tool, that I was trying to use with the ItemGraph to make more sense of the former.

Given an ID from ListA (we'll call it ListA), Use the ItemGraph (let's call it org_graph, b/c that's its name) to Get information in a format more easy for me than the alphanumeric ID string:

for each ID in ListA:
     a_Node=org_graph.get_node(ID)
     a_Item=a_Node.item
     
     item_title=a_Item.title
     item_url=a_Item.homepage
     print(f'{ID}   {item_title}   {item_url}')

And such a basic loop seemed to work okay, right up until it didn't.

I discovered IDs that led to Nodes that could not result in an Item.

Adding a try/catch pair into my loop allowed me to get results a bit more smoothly.
If a_Node.item were to create an error, the ID was added to a List called nonitems.

Now, I can loop through the nonitems List to get a bit more information:

for each ID in nonitems:
     a_Node=org_graph.get_node(ID)
     a_type=type(a_Node)
     a_link=f'https://www.arcgis.com/home/item.html?id={ID}'
     print(f'{ID}   {a_type}   {a_link}')

Herein lies the problem for me...

Most of the Nodes are of type <class 'NoneType'>, though there is also a <class 'arcgis.apps.itemgraph._item_graph.ItemNode'>.

The latter resolves into a "The item you requested cannot be found. The item may have been deleted or you may have entered an incorrect URL." statement.

The NoneType Nodes are invariably real things!
I have to visit each hyperlink via mouse-click to find this out though...

  • CSV collection (from Survey123)
  • Microsoft Excel (from Survey123)
  • Data Pipeline
  • Shapefile
  • Web map
  • Notebook
  • Basemap
  • etc.

Do you know any Pythonic way to determine what an ItemGraph Node might be, when the Notebook & GIS I'm using to interact with it thinks it is of NoneType?

AttributeError: 'NoneType' object has no attribute 'get_data'

0 Kudos
2 Replies
GIS_utahDEM
Frequent Contributor

I don't think I have a solution to your problem -- but I'm doing something very similar for my organization! This script has been successfully running for a couple weeks every night and is populating/updating a layer I use in the attached dashboard (we're also using the layer to track updates to meet the new accessibility requirements). 

Best of luck! 

Screenshot 2026-06-17 102724.png

0 Kudos
ODWC_GIS
Frequent Contributor

That's an amazing project!  

The 'Parse out the itemgraph into nodes (content items), downstream edges and upstream edges' section has given me some ideas.  Thank you very much for your help!

0 Kudos