Skip to content

Crashes when parsing a 3MF file with metadatagroup field in object #53

@gyscos

Description

@gyscos

I have a 3MF file generated by onShape. It seems to include a metadatagroup field in the object tag, where this crate currently expects a single tag, either mesh or component.

Here is the beginning of my file:

<?xml version="1.0" encoding="utf-8"?>
<model xmlns="http://schemas.microsoft.com/3dmanufacturing/core/2015/02" unit="meter" xml:lang="en-US" xmlns:m="http://schemas.microsoft.com/3dmanufacturing/material/2015/02" xmlns:p="http://schemas.microsoft.com/3dmanufacturing/production/2015/06" xmlns:b="http://schemas.microsoft.com/3dmanufacturing/beamlattice/2017/02" xmlns:s="http://schemas.microsoft.com/3dmanufacturing/slice/2015/07" xmlns:sc="http://schemas.microsoft.com/3dmanufacturing/securecontent/2019/04" xmlns:customXMLNS0="extensions">
	<resources>
		<m:colorgroup id="1">
			<m:color color="#C4E2F3FF"/>
			<m:color color="#3B61B4FF"/>
		</m:colorgroup>
		<object id="2" name="Part 2" type="model" p:UUID="5690f40c-430c-479f-b804-29081051c247" pid="1" pindex="0">
			<metadatagroup>
				<metadata name="customXMLNS0:PTC_onshape_metadata" type="entity_type">Body</metadata>
			</metadatagroup>
			<mesh>
				<vertices>
					<vertex x="0.14470075" y="-0.02387521" z="-0.09085463" />
					<vertex x="0.14421695" y="-0.02435900" z="-0.09359834" />
...

Here is a zip file with the 3MF inside for reproduction:
Flower Pot.zip

When trying to load this, I get this error:

ERROR - Application error: Deserialization error from xml reading

Which is really caused by this error:

DeError(Custom("unknown variant `metadatagroup`, expected `mesh` or `components`"))

Seems like the current model for ObjectData is an enum which indeed doesn't like to see this metadatagroup.

I'm not sure we can ask serde to ignore this field, so we may need to replace this enum with a struct containing both a mesh and a component optional fields, only one of them being non-None.

EDIT: here's an example from the 3MF specs showing this same situation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions