ruby / ruby/psych

Got "found undefined tag" error on parsing prefab file of unity3d

Open
#404 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
597
Forks
223
Avg merge
11h 23m
Merged PRs (30d)
3

Description

"found undefined tag handle while parsing a node at line 21 column 5 (Psych::SyntaxError)"
I got this error on parsing unity3d prefab file with parse_stream method.

Psych.parse_stream(yaml, filename: path) do |node|
       puts node
end

line 21 is " --- !u!224 &224286004637740336"
I can insert a new line "%TAG !u! tag:unity3d.com,2011: " before every "---" to fix it.

source.gsub(/^(?<!%TAG !u! tag:unity3d.com,2011:\n)^(--- !u![0-9]+ &[0-9]+)$/, "%TAG !u! tag:unity3d.com,2011:\n\\1")

But I hope there is a solution in API level.

%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &1007462957078648
GameObject:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  serializedVersion: 6
  m_Component:
  - component: {fileID: 224286004637740336}
  - component: {fileID: 222770377023727128}
  - component: {fileID: 114746315234884256}
  m_Layer: 5
  m_Name: Icon
  m_TagString: Untagged
  m_Icon: {fileID: 0}
  m_NavMeshLayer: 0
  m_StaticEditorFlags: 0
  m_IsActive: 1
--- !u!224 &224286004637740336
RectTransform:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 1007462957078648}
  m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
  m_LocalPosition: {x: 0, y: 0, z: -1.3}
  m_LocalScale: {x: 0.7, y: 0.7, z: 0.9996802}
  m_Children: []
  m_Father: {fileID: 224567198966254662}
  m_RootOrder: 0
  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
  m_AnchorMin: {x: 0.5, y: 0.5}
  m_AnchorMax: {x: 0.5, y: 0.5}
  m_AnchoredPosition: {x: 45.3, y: -79.2}
  m_SizeDelta: {x: 132, y: 132}
  m_Pivot: {x: 0.5, y: 0.5}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Psych.parse_stream and the supplied Unity YAML, especially the document boundary at line 21 and its %TAG directive. Reproduce the Psych::SyntaxError, then inspect how multi-document directives and tags are handled. Done means the sample parses through the API without requiring preprocessing, with a regression test for the provided input.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby, yaml
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.