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

Correctly handle comments on a LexEntry that doesn't have a lexeme #212

Open
rmunn opened this issue Apr 22, 2022 · 3 comments
Open

Correctly handle comments on a LexEntry that doesn't have a lexeme #212

rmunn opened this issue Apr 22, 2022 · 3 comments
Assignees

Comments

@rmunn
Copy link
Collaborator

rmunn commented Apr 22, 2022

One project failed Send/Receive on the line var lexeme = GetLexEntry(comment.EntryRef).Lexeme.FirstNonEmptyString(); in ComvertMongoToLcmComments.cs, with a NullReferenceException. On investigation, the entry was missing a lexeme in Mongo, and so Lexeme.FirstNonEmptyString() was null.FirstNonEmptyString(). The only thing that the lexeme variable is used for in that code is fo human-readable text, so that line should be replaced with:

var lexeme = GetLexEntry(comment.EntryRef).Lexeme;
var lexemeText = (lexeme == null) ? "(no lexeme)" : FirstNonEmptyString();

Or, once we can use modern versions of C# (i.e. once we drop Mono 5):

var lexeme = GetLexEntry(comment.EntryRef)?.Lexeme?.FirstNonEmptyString() ?? "(no lexeme)";
@jasonleenaylor
Copy link

I'm pretty sure you can already use that with mono5. There are other new features that you can't.

@megahirt
Copy link
Contributor

This seams like the fix is already thought out here.

Error repro steps:

  • start with working Flex / LF send/receive project
  • delete the data in the lexeme field for the entry (should this even be allowed?)
  • do a S/R and see the error in LFMerge

@josephmyers this seems like a good candidate for testing out the "skip exceptions" feature that we recently developed.

@megahirt megahirt changed the title Correclty handle comments on a LexEntry that doesn't have a lexeme Correctly handle comments on a LexEntry that doesn't have a lexeme Sep 26, 2022
@megahirt
Copy link
Contributor

megahirt commented Oct 6, 2022

I wonder if the steps to trigger a "comment exception" could be:

  • comment on an entry in LF
  • delete the text in the lexeme field
  • do a send/receive and see if we get the error (and if we do, then we should fix this issue)

c.f. sillsdev/web-languageforge#1444

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

4 participants