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

"Publish" call fails when page names have >=4(3?) white spaces #5

Closed
FerranC96 opened this issue Jun 18, 2022 · 3 comments
Closed

"Publish" call fails when page names have >=4(3?) white spaces #5

FerranC96 opened this issue Jun 18, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@FerranC96
Copy link

Also using the same config as in #3

The final issue appears with both $conversion = 'markdown-...' and $conversion = 'markdown_github-...' anytime a page has at least 4 white spaces in its name (not fully tested the minimum replication requirements, it could perhaps be present with as low as 3 spaces). This issue only affects the .docx to .md generation (thus with .pdf outputs remaining fine) and is accompanied by the following error message:

  • Failed to convert page: SectionGroup\Section\“PAGE NAME WITH A BUT-LOAD OF WHITE SPACES”. Reason: Error while publishing page to docx file path\{...}{...}{...}-123456-“PAGE NAME WITH A BUT-LOAD OF WHITE SPACES”.docx: Exception calling "Publish" with "4" argument(s): "Exception from HRESULT: 0x80042006" Convert-OneNotePage : Failed to convert page: SectionGroup\Section\“PAGE NAME WITH A BUT-LOAD OF WHITE SPACES”. Reason: Error while publishing page to docx file....: Exception calling "Publish" with "4" argument(s): "Exception from HRESULT: 0x80042006"

Here, there's clearly something wrong with the Publish call whenever the name has multiple white spaces, resulting in space-flanked page name substrings to be parsed as additional arguments to the function call.

Thanks again for everything @alopezrivera ! 🥇

@alopezrivera
Copy link
Owner

alopezrivera commented Jun 18, 2022

Hey again! Unfortunately I can't replicate the issue even with your "PAGE NAME WITH A BUT-LOAD OF WHITE SPACES" :/

I am using PowerShell 5.1.19041.1682. Would you mind testing with the latest version of owo and PowerShell 5.1.19041.1682 (or about I guess) and seeing if the issue persists?


My first impression was that it must have to do with how arguments are passed to Publish-OneNotePage in Conversion-Page.psm1, however, argument passing would become a problem from a single white space onward (as PowerShell would think you're passing two arguments instead of a single one -being the title of your note).

@alopezrivera
Copy link
Owner

alopezrivera commented Jul 2, 2022

I just realized today that notebooks with spaces in their names would cause an error when exporting, because the path to the media folder of each notebook/section was passed to pandoc unquoted. As command line applications separate their arguments with spaces, paths with spaces in them need to be passed between quotes.

Commit ef5089f ensures this. This should make owo pretty bulletproof to strange paths. Maybe it helps for this issue as well.

@alopezrivera alopezrivera added the bug Something isn't working label Jul 2, 2022
@alopezrivera
Copy link
Owner

alopezrivera commented Jul 2, 2022

I have finally managed to replicate the error, but with a ridiculously long note title: "Lossless Convexification of a Class of Optimal Control Problems with Non-Convex Control Constraints".

I got the following error trace when trying to export:

Failed to convert page: Literature\Lossless Convexification of a Class of Optimal Control Problems with Non-Convex Control Constraints. Reason: Error while publishing page to docx file C:\Users\USER\Downloads\owo\DARE Control Research 
Team\docx\{7C190706-4F2C-49DC-AB3A-E3071A8392C0}{1}{E19480354296818762984220141545776511851869801}-1623769902-Lossless Convexification of a Class of Optimal Control Problems with Non-Convex Control Constraints.docx: Exception calling "Publish" with "4" argument(s): "Exception from HRESULT: 0x80042006"
Convert-OneNotePage : Failed to convert page: Literature\Lossless Convexification of a Class of Optimal Control 
Problems with Non-Convex Control Constraints. Reason: Error while publishing page to docx file 
C:\Users\USER\Downloads\owo\DARE Control Research Team\docx\{7C190706-4F2C-49DC-AB3A-E3071A8392C0}{1}{E1948035429681 
8762984220141545776511851869801}-1623769902-Lossless Convexification of a Class of Optimal Control Problems with      
Non-Convex Control Constraints.docx: Exception calling "Publish" with "4" argument(s): "Exception from HRESULT:       
0x80042006"
At C:\Users\USER\Desktop\home\projects\owo\owo.ps1:58 char:257
+ ... onConfigs | Convert-OneNotePage -OneNoteConnection $OneNote -Config $ ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Convert-OneNotePage

After some research and judging from the FullyQualifiedErrorId, it seems the OneNote export process just cannot write the file named C:\Users\USER\Downloads\owo\DARE Control Research Team\docx\{7C190706-4F2C-49DC-AB3A-E3071A8392C0}{1}{E19480354296818762984220141545776511851869801}-1623769902-Lossless Convexification of a Class of Optimal Control Problems with Non-Convex Control Constraints.docx.

I then deleted the last few words in the title and tried again, and it worked.

I am fairly certain the cause of this issue is the maximum number of characters allowed in Windows paths. I suggest you try exporting your notes inside a directory "closer" to C:\, or if that is not possible, reducing the length of your titles, and restoring them afterwards.

As to the numbers in the .docx files owo produces -arguably the longest part of their paths-, they contain the OneNote note ID of the note they were generated from, as well as the timestamp of their last modification. This allows owo to reuse .docx files after they are generated, as well as to not do so if you have modified the note since then. If you believe owo should do this in a better way please feel free to open a new issue about .docx file naming.

In the meantime, I consider this issue to be closed.

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

No branches or pull requests

2 participants