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

Improve comment about magic word not present. #318

Merged

Conversation

lnogueir
Copy link
Contributor

@lnogueir lnogueir commented May 29, 2024

Just fixing a little bug I stumbled upon while navigating the codebase.

Improving comments only.

Copy link
Contributor Author

@lnogueir lnogueir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After reading this comment, this is on purpose?

read.go Outdated
@@ -160,7 +163,7 @@ func (r *reader) readHeader() ([]*Element, error) {
return nil, err
}
if string(data[128:]) != magicWord {
return nil, nil
return nil, ErrorMagicWord
Copy link
Owner

@suyashkumar suyashkumar May 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the reason for this was the note at L157: namely, if the magic word isn't found we try to parse the Dataset without the preamble: #59. This was reported by folks who had files like this in production! Perhaps we should make the user pass an explicit parse option to trigger this behavior if we think there's harm in doing this as a default.

Of course, parsing without metadata can cause all sorts of problems which may eventually result in an error anyway.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wkoszek do y'all recall if this fix actually lead to y'all successfully parsing DICOMs without the header?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. I reverted the commit, but I updated the comment because it's rather unusual to see a function returning nil, nil like that and the comment was a bit hidden up top. Will update PR title

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, thanks for the update!

@suyashkumar
Copy link
Owner

After reading this comment, this is on purpose?

Yep, I think it was indeed intentional: #59

@lnogueir lnogueir changed the title Fix invalid magic word returning nil error Improve comment explaining behaviour when magic word is not present. May 29, 2024
@lnogueir lnogueir changed the title Improve comment explaining behaviour when magic word is not present. Improve comment about magic word not present. May 29, 2024
@suyashkumar suyashkumar merged commit bb750f0 into suyashkumar:main May 29, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants