Crash when merging DOCX files without custom properties
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 45/100
Research direction
Start by reproducing a merge with a DOCX file that has no custom properties, then inspect the shown custom-property PID calculation and its surrounding code. No source file or test path is named in the issue. Done means merging such files completes without the Sequence contains no elements exception, with the existing behavior preserved for files that have custom properties.
Written by the indexing model from the issue text.
Description
I'm encountering an error when merging DOCX files. The exception thrown is System.InvalidOperationException: Sequence contains no elements, which happens with some files I add to the merge list.
I downloaded the source code to investigate the issue, and it turns out that the files causing the problem apparently do not have custom properties, leading to an error in this block:
`IEnumerable pids =
(
from d in remote_custom_document.Root.Descendants()
where d.Name.LocalName == "property"
select int.Parse( d.Attribute( XName.Get( "pid" ) ).Value )
);
int pid = pids.Max() + 1;`
I fixed the issue by checking if pids contains any elements and setting the value to 1 if it doesn't:
int pid = pids.Any() ? pids.Max() + 1 : 1;
I don't know much about the internal structure of DOCX files, so I’d like to ask: Is this fix valid? If so, should I submit a PR to fix it?"
- Dominant language
- C#
- Stars
- 1.9k
- Forks
- 483
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from xceedsoftware/DocX
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
xceedsoftware/DocX#489 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
xceedsoftware/DocX#488 · 1 comment · 1 reaction ·
-
keep format Open
Difficulty 3/5 1-2 days Newbie friendliness 25/100
xceedsoftware/DocX#487 · 3 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
xceedsoftware/DocX#482 · 4 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
xceedsoftware/DocX#481 · 1 comment ·
All issues in xceedsoftware/DocX
Similar issues
-
type/automation type/tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
t/bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
ci-failure-cause test-failure
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
area:auth FE mvp P3
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
klasolsson81/jobbliggaren#1788 ·