Skip to content

[SR-6294] Standard Library (PropertyList and JSON) Decoders Do Not Propagate {{codingPath}} Correctly  #4491

Open
@swift-ci

Description

@swift-ci
Previous ID SR-6294
Radar None
Original Reporter iosdevzone (JIRA User)
Type Bug

Attachment: Download

Additional Detail from JIRA
Votes 2
Component/s Foundation
Labels Bug, Codable
Assignee None
Priority Medium

md5: 122fc73699f6bf537d03028c69343aa7

Issue Description:

The current Swift Standard Library implementations of JSONDecoder and PropertyListDecoder do not properly propagate `codingPath` for nested containers.

The attached playground shows the asymmetry between encoders and decoders (I created the playground to ensure that nested containers should have access to the full encoding path: encoders seem to, decoders don't – one or other should be true for both – I wanted to make sure it was not my misunderstanding.)

Using https://github.com/apple/swift/blob/master/stdlib/public/SDK/Foundation/JSONEncoder.swift

as a reference, the root cause of the problem can be found at lines: 1247, 1265, 1587, 1613; if nested containers use the decoder's codingPath and not their own to create children, well, the path will not be passed on.

Looking at the tests it seems there were not tests to examine decoder paths.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions