ssssssss-team/spider-flow · error · Error

" + e.message + " for " + child.nodeName

Error message

" + e.message + " for " + child.nodeName

What it means

During XML decoding, mxGraph's codec wraps failures from addObjectValue (e.g. setting a field on the decoded object) and rethrows them as Error(e.message + ' for ' + child.nodeName), annotating which XML child element caused the failure. It is an error-context wrapper, not a distinct failure mode.

Solutions

  1. Read the wrapped e.message to identify the field, then fix the offending XML child element's value/format.
  2. Regenerate or re-save the diagram with a compatible mxGraph version.
  3. Add/repair a codec mapping (mxCodecRegistry) if a custom class or field changed name.

Example fix

// before (XML)
<mxGeometry width="abc" .../>
// after
<mxGeometry width="120" .../>
Defensive patterns

Strategy: try-catch

Validate before calling

// Validate XML values before decode: ensure numeric fields parse and known fields match the mxGraph schema version
Array.prototype.forEach.call(doc.querySelectorAll('[width],[height],[x],[y]'), function(el){ ['width','height','x','y'].forEach(function(a){ var v = el.getAttribute(a); if (v !== '' && isNaN(Number(v))) throw new Error('Bad numeric attribute ' + a + '=' + v); }); });

Try / catch

try {
  obj = codec.decode(node);
} catch (e) {
  // e.message ends with ' for <nodeName>' identifying the failing XML element
  console.error('Decode failed at element:', e.message.split(' for ').pop(), e.message);
  throw e;
}

Prevention

When it happens

Trigger: Decoding graph XML where a child element maps to a field whose value cannot be applied (wrong value type for the field, unknown enum/number string, codec for the child's type throwing internally).

Common situations: Hand-edited or version-mismatched graph XML (attribute written for an older/newer mxGraph schema), corrupt saved diagrams, custom codecs that throw on unexpected values.

Understand the failure class

Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.

Related errors


AI-assisted analysis of ssssssss-team/spider-flow@c799cca99c (2026-09-08). Data as JSON: /api/errors/be75b9940192df89. Report an issue: GitHub.

Appendix: source

Thrown at spider-flow-web/src/main/resources/static/js/mxgraph/mxgraph.js:87859

			value = child.getAttribute('value');
			
			if (value == null && mxObjectCodec.allowEval)
			{
				value = mxUtils.eval(mxUtils.getTextContent(child));
			}
		}
		else
		{
			value = dec.decode(child, template);
		}

		try
		{
			this.addObjectValue(obj, fieldname, value, template);
		}
		catch (e)
		{
			throw new Error(e.message + ' for ' + child.nodeName);
		}
	}
};

/**
 * Function: getFieldTemplate
 * 
 * Returns the template instance for the given field. This returns the
 * value of the field, null if the value is an array or an empty collection
 * if the value is a collection. The value is then used to populate the
 * field for a new instance. For strongly typed languages it may be
 * required to override this to return the correct collection instance
 * based on the encoded child.
 */	
mxObjectCodec.prototype.getFieldTemplate = function(obj, fieldname, child)
{
	var template = obj[fieldname];
	

View on GitHub (pinned to c799cca99c)