Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot initialize SchemaType from invalid String value #136

Closed
nunogoncalves opened this issue Dec 3, 2020 · 2 comments · Fixed by #138
Closed

Cannot initialize SchemaType from invalid String value #136

nunogoncalves opened this issue Dec 3, 2020 · 2 comments · Fixed by #138
Assignees
Labels
bug Something isn't working

Comments

@nunogoncalves
Copy link

Hi!

Version

0.13.0

Description of the bug

I'm having issues opening one excel that I've got. This is my excel version.

Screenshot 2020-12-03 at 00 31 04

Steps to reproduce

My code is very simple just taking the lib for a spin as documented in the README:

guard let file = XLSXFile(filepath: filepath) else {
  fatalError("XLSX file at \(filepath) is corrupted or does not exist")
}

for wbk in try file.parseWorkbooks() {

  for (name, path) in try file.parseWorksheetPathsAndNames(workbook: wbk) {
    if let worksheetName = name {
      print("This worksheet has a name: \(worksheetName)")
    }
  }
}

I get the following error:

Fatal error: Error raised at top level: Swift.DecodingError.dataCorrupted(Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "relationship", intValue: nil), XMLKey(stringValue: "1", intValue: 1), XMLKey(stringValue: "1", intValue: 1), CodingKeys(stringValue: "type", intValue: nil)], debugDescription: "Cannot initialize SchemaType from invalid String value http://schemas.microsoft.com/office/2011/relationships/webextensiontaskpanes", underlyingError: nil)): file Swift/ErrorType.swift, line 200
2020-12-03 00:25:57.843915+0000 Budgets[19537:709926] Fatal error: Error raised at top level: Swift.DecodingError.dataCorrupted(Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "relationship", intValue: nil), XMLKey(stringValue: "1", intValue: 1), XMLKey(stringValue: "1", intValue: 1), CodingKeys(stringValue: "type", intValue: nil)], debugDescription: "Cannot initialize SchemaType from invalid String value http://schemas.microsoft.com/office/2011/relationships/webextensiontaskpanes", underlyingError: nil)): file Swift/ErrorType.swift, line 200

TLDR:

Cannot initialize SchemaType from invalid String value http://schemas.microsoft.com/office/2011/relationships/webextensiontaskpanes"

Taking a look at

public struct Relationship: Codable, Equatable {
  public enum SchemaType: String, Codable {

all the cases are expecting a http://schemas.openxmlformats.org/officeDocument/2006/relationships/\ so I guess that might be the issue here?

Expected behavior

Worksheets could be printed out.

File for reproduction

faulty_worksheet.xlsx.zip
Additional context

Creating a new file seems to work fine, so I copied my faulty file and started to remove stuff until I eventually got an empty one which still fails.
I guess worth mentioning is that I have an add-on on this document. But even after removing it it threw the same error.
I hope you guys with your deeper knowledge can see what's going on a lot faster than I can.

Thank you!

@MaxDesiatov MaxDesiatov added the bug Something isn't working label Dec 3, 2020
@MaxDesiatov
Copy link
Collaborator

Hi @nunogoncalves, thank you for reporting this issue. It should be an easy fix, and I'm going to create a PR with it later today. Would you mind if your file is used as a test case for it? If confirm you agree to it, it would be added to the repository and shared under the terms of the Apache 2.0 license. No pressure at all if you don't want that, I can create an isolated test case without it.

@nunogoncalves
Copy link
Author

Sure. Go ahead.

@MaxDesiatov MaxDesiatov changed the title Cannot initialize SchemaType from invalid String value http://schemas.microsoft.com/office/2011/relationships/webextensiontaskpanes Cannot initialize SchemaType from invalid String value Dec 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants