Why Does RunConveyor Report an Invalid Item Error?

Patricia Callen5 min read
Other ManufacturerRoboticsTroubleshooting
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

RunConveyor stops because the program calls Delete() with an item identifier that is already invalid, no longer exists, or no longer matches the intended object. Delete the part once after confirming it has left the conveyor, then remove its reference from the program's collection without separately forcing nobjects out of sync. Look at the trend first: trace the pose, inside/outside result, object index, and deletion state before changing the conveyor logic.

What does the invalid-item symptom mean?

The reported exception is Exception: Invalid item provided: The item identifier provided is not valid or it does not exist. This is an object-lifecycle failure, not proof that the conveyor boundary test is wrong. The runtime received an identifier that it could not resolve to a live item.

The first deletion may succeed and invalidate the program's stored reference. If a later scan, loop iteration, or second code path calls objects[i].Delete() again, the same reference now points to an item that no longer exists. A similar failure occurs when decrementing nobjects leaves indexing, loop bounds, and the actual contents of objects inconsistent.

Read the sequence surrounding the exception. If the part disappears before the error, suspect a repeated deletion or stale reference. If it never disappears, inspect whether objects[i] was valid before the call and whether index i identifies the intended part.

How does the signal chain create this failure?

The measured value is the part pose, represented in the example by newposei. The controller passes that pose to is_inside_conveyor(newposei). A false result commands the final action, obj_i.Delete() or the corresponding objects[i].Delete().

Signal or state Source Wrong-value symptom
newposei Current part pose A stale or mismatched pose can classify the wrong part as outside.
is_inside_conveyor(newposei) Conveyor-boundary test A false result at the wrong point requests premature deletion.
i Object-loop index An index changed during iteration can select a different or nonexistent entry.
objects[i] or obj_i Stored item reference A stale reference produces the invalid-item exception.
nobjects Program-maintained object count A count that differs from the collection length causes skipped entries or invalid indexing.

The deletion call changes the state that the loop is traversing. Once an item is deleted, every stored alias to that item must be treated as invalid. Tuning does not fix wiring, and changing the boundary calculation does not repair a stale object reference.

Which checks isolate the failing state?

  1. Record the loop index i, the current value of nobjects, and the collection length immediately before deletion. The count and the collection must describe the same live entries.

  2. Record the identity or handle represented by objects[i], then confirm it refers to the same part whose pose supplied newposei. A pose from one part must not control deletion of another.

  3. Record the result of is_inside_conveyor(newposei) on successive iterations. Confirm that the outside transition occurs once as the part reaches the conveyor end.

  4. Search the program flow for every path that can call Delete(). A cleanup routine, conveyor routine, and exception handler must not independently delete the same item.

  5. Observe whether the graphical or runtime item disappears before the exception. Disappearance followed by an exception identifies a second use of the invalidated reference.

Do not begin by changing the conveyor limits. The decisive measurement is whether a live identifier enters Delete() exactly once.

How should the deletion procedure be structured?

  1. Evaluate the current pose and store the result of the boundary test for the current part.

  2. If the part remains inside, leave its reference and collection membership unchanged.

  3. If the part is outside, confirm that its stored item reference is still valid using the API's item-validity facility, if one is provided.

  4. Call Delete() once for that live item.

  5. Immediately remove or invalidate the corresponding entry in objects. Do not leave a deleted identifier available to the next iteration.

  6. Derive nobjects from the updated collection when possible. If it must be maintained separately, update it in the same operation as collection removal.

  7. Continue iteration using a method that accounts for removal. Reverse traversal, deferred removal, or rebuilding the live-object collection prevents an index shift from skipping the next part.

if not is_inside_conveyor(newposei):
    # Confirm obj_i is still a live item using the API's validity check.
    obj_i.Delete()
    # Remove or invalidate the matching stored reference.
    # Recalculate nobjects from the remaining collection.

The validity check is a guard against stale state, not a replacement for correct ownership. One routine should own deletion, while other routines only report that a part has reached the removal condition.

How do you verify that the correction works?

Run a test with one part and trace its full lifecycle: created, tracked inside the conveyor, classified outside, deleted, and removed from the collection. The test passes when the part disappears once, the program continues, and no later iteration accesses its former identifier.

Then repeat with multiple parts close enough in sequence to exercise collection removal while the loop is active. Confirm that each remaining part keeps the correct pose-to-reference association, no part is skipped after an index shift, and nobjects matches the live collection after every deletion.

Finally, exercise any stop, reset, or cleanup path that also deletes parts. Each path must tolerate an empty collection and must not reuse identifiers invalidated by RunConveyor.

Which pitfalls recur in conveyor object cleanup?

Deleting directly from a forward-indexed collection can shift later elements while i continues to advance. The result may be a skipped part on one iteration and a stale or out-of-range selection later. Deferred deletion or reverse traversal separates classification from collection mutation.

Manually decrementing nobjects without removing the same element from objects creates two competing descriptions of state. Conversely, removing an element without updating a separately maintained count can extend the loop beyond the live entries.

Another recurring error is using newposei from the current part while calling Delete() on a reference retained from a previous iteration. Keep pose, boundary result, and item reference together as one per-part record throughout the loop.

FAQ

How do I prevent RunConveyor from deleting the same part twice?

Give one routine ownership of Delete(), remove or invalidate the stored reference immediately after deletion, and exclude that entry from later iterations.

How do I keep nobjects synchronized after objects[i].Delete()?

Remove the matching entry from objects and derive nobjects from the remaining collection. If the count must be separate, update the collection and count in one operation.

How do I troubleshoot an invalid item that still stops the program?

Capture the item identifier, i, nobjects, collection length, newposei, and boundary-test result immediately before every deletion. Stop changing the application when a supposedly live identifier fails its validity check or the exception occurs on the first deletion attempt; escalate to the product's official support channel with the exact exception, a minimal reproducible program, and the captured lifecycle trace.

Back to blog