juicedata/juicefs · error

unexpected %v

Error message

unexpected %v

What it means

During JSON load of a metadata dump, the decoder encountered a token where the closing '}' of an entry object was expected but found something else (e.g. a value or another delimiter). This is thrown by writeFiles/readFiles while parsing the `files` section of a dump. It means the dump file is structurally malformed at that point.

Source

Thrown at pkg/meta/dump.go:620

					usedInodes++
				}
				if err == nil {
					i := e.Attr.Inode
					for {
						if q := quotas[i]; q != nil {
							q.UsedSpace += usedSpace
							q.UsedInodes += usedInodes
						}
						if i <= 1 || len(parents[i]) == 0 {
							break
						}
						i = parents[i][0]
					}

					var t json.Token
					t, err = dec.Token()
					if err == nil && t != json.Delim('}') {
						err = fmt.Errorf("unexpected %v", t)
					}
				}
			}
		case "symlink":
			err = dec.Decode(&e.Symlink)
		case "xattrs":
			err = dec.Decode(&e.Xattrs)
		case "posix_acl_access":
			err = dec.Decode(&e.AccessACL)
		case "posix_acl_default":
			err = dec.Decode(&e.DefaultACL)
		}
		if err != nil {
			return nil, fmt.Errorf("decode %v: %s", name, err)
		}
	}
	if len(e.Parents) == 1 {
		load(&e)

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Validate the dump file with a JSON checker (jsonlint or `python -m json.tool`) to locate the malformed entry.
  2. Re-create the dump with `juicefs dump` from a healthy metadata engine and retry the load.
  3. Check that the dump file was not truncated in transfer; compare size/checksum with the source.
  4. If hand-editing was done, restore the original entry object structure including its closing brace.

Example fix

// before: loading a truncated/hand-edited dump
$ juicefs load sqlite3://meta.db bad.dump
// after: regenerate and verify
$ juicefs dump redis://origin/myfs good.dump
$ python3 -m json.tool good.dump > /dev/null && juicefs load sqlite3://meta.db good.dump
Defensive patterns

Strategy: validation

Validate before calling

python3 -m json.tool dump.json > /dev/null  # validate dump before juicefs load

Prevention

When it happens

Trigger: juicefs load/restore reads a dump file whose entry object is not terminated by '}' — e.g. the file was truncated, hand-edited, or produced by a broken writer so the JSON stream contains a non-'}' token after the entry's fields.

Common situations: Restoring a backup that was cut short mid-write; concatenating or editing dump files manually; loading a dump written by a buggy/older tool that emitted malformed JSON for an entry.

Understand the failure class

Background: "failed to unmarshal" / json.Unmarshal errors: why parsing a response into a Go struct fails and how to fix it — this error's family across 23 libraries.

Related errors


AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06). Data as JSON: /api/errors/1b6f0a4a37779a0c. Report an issue: GitHub.