Bug 571143 - InvalidPatternException: Not closed bracket? in error log
Summary: InvalidPatternException: Not closed bracket? in error log
Status: RESOLVED FIXED
Alias: None
Product: JGit
Classification: Technology
Component: JGit (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 5.11   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-02-12 01:33 EST by Christoph Laeubrich CLA
Modified: 2021-09-21 09:38 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christoph Laeubrich CLA 2021-02-12 01:33:53 EST
I see this occasionally on the error log.

If it "could happen sometimes" it should either be ignored , if its a user error, the user should be made aware what he/she can do, if its an internal error it should be fixed.

org.eclipse.jgit.errors.InvalidPatternException: Not closed bracket?
	at org.eclipse.jgit.ignore.internal.Strings.convertGlob(Strings.java:409)
	at org.eclipse.jgit.ignore.internal.WildCardMatcher.<init>(WildCardMatcher.java:31)
	at org.eclipse.jgit.ignore.internal.PathMatcher.createNameMatcher0(PathMatcher.java:146)
	at org.eclipse.jgit.ignore.internal.PathMatcher.createPathMatcher(PathMatcher.java:104)
	at org.eclipse.jgit.ignore.FastIgnoreRule.<init>(FastIgnoreRule.java:95)
	at org.eclipse.jgit.ignore.IgnoreNode.parse(IgnoreNode.java:82)
	at org.eclipse.jgit.treewalk.WorkingTreeIterator$PerDirectoryIgnoreNode.load(WorkingTreeIterator.java:1285)
	at org.eclipse.jgit.treewalk.WorkingTreeIterator.getIgnoreNode(WorkingTreeIterator.java:752)
	at org.eclipse.jgit.treewalk.WorkingTreeIterator.isDirectoryIgnored(WorkingTreeIterator.java:1549)
	at org.eclipse.jgit.treewalk.WorkingTreeIterator.isDirectoryIgnored(WorkingTreeIterator.java:1527)
	at org.eclipse.jgit.treewalk.WorkingTreeIterator.isEntryIgnored(WorkingTreeIterator.java:734)
	at org.eclipse.jgit.treewalk.WorkingTreeIterator.isEntryIgnored(WorkingTreeIterator.java:694)
	at org.eclipse.jgit.treewalk.WorkingTreeIterator.isEntryIgnored(WorkingTreeIterator.java:681)
	at org.eclipse.jgit.treewalk.filter.IndexDiffFilter.include(IndexDiffFilter.java:137)
	at org.eclipse.jgit.treewalk.filter.TreeFilter.matchFilter(TreeFilter.java:195)
	at org.eclipse.jgit.treewalk.filter.AndTreeFilter$List.matchFilter(AndTreeFilter.java:157)
	at org.eclipse.jgit.treewalk.TreeWalk.next(TreeWalk.java:820)
	at org.eclipse.jgit.lib.IndexDiff.diff(IndexDiff.java:477)
	at org.eclipse.egit.core.internal.indexdiff.IndexDiffCacheEntry.lambda$6(IndexDiffCacheEntry.java:687)
	at org.eclipse.egit.core.UnitOfWork.run(UnitOfWork.java:115)
	at org.eclipse.egit.core.internal.indexdiff.IndexDiffCacheEntry.calcIndexDiffDataFull(IndexDiffCacheEntry.java:680)
	at org.eclipse.egit.core.internal.indexdiff.IndexDiffCacheEntry.access$8(IndexDiffCacheEntry.java:674)
	at org.eclipse.egit.core.internal.indexdiff.IndexDiffCacheEntry$4.run(IndexDiffCacheEntry.java:420)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Comment 1 Thomas Wolf CLA 2021-02-12 03:25:45 EST
Can you show the content of all .gitignore files in the repository, plus the content of any global ignore files (configured via core.excludesfile)? Either there is a wrong ignore pattern, or there is a correct pattern that JGit cannot handle.
Comment 2 Thomas Wolf CLA 2021-02-23 06:52:13 EST
@Christoph: any news here?

As far as JGit development is concerned: it would be good if the exception included the wrong pattern and the file name it occurs in.
Comment 3 Eclipse Genie CLA 2021-02-23 07:14:41 EST
New Gerrit change created: https://git.eclipse.org/r/c/jgit/jgit/+/176731
Comment 4 Thomas Wolf CLA 2021-02-23 07:16:43 EST
(In reply to Eclipse Genie from comment #3)
> New Gerrit change created: https://git.eclipse.org/r/c/jgit/jgit/+/176731

This includes the pattern in the log entry. Including the file path is more complicated and will have to be done later.
Comment 5 Christoph Laeubrich CLA 2021-02-23 07:18:41 EST
Thanks, I'll keep an eye on this if I can find the culprit with the enhanced message!
The problem is that I have a workspace with hundreds of .gitignores and its a bit hard to find what might be the cause.
Comment 6 Thomas Wolf CLA 2021-02-23 07:31:15 EST
(In reply to Christoph Laeubrich from comment #5)
> Thanks, I'll keep an eye on this if I can find the culprit with the enhanced
> message!
> The problem is that I have a workspace with hundreds of .gitignores and its
> a bit hard to find what might be the cause.

If you can find them all (via find . -name ".gitignore" or similar) and cat them all together and send me the file (or post it here), I could run them all through FastIgnoreRule and thus find the culprit quickly.

If core.excludesFile is set, there may be more rules in the file specified there.
Comment 7 Eclipse Genie CLA 2021-02-23 12:12:52 EST
New Gerrit change created: https://git.eclipse.org/r/c/jgit/jgit/+/176744
Comment 8 Thomas Wolf CLA 2021-02-23 12:15:40 EST
(In reply to Eclipse Genie from comment #7)
> New Gerrit change created: https://git.eclipse.org/r/c/jgit/jgit/+/176744
Adds filename and line number to the exception message.
Comment 11 Matthias Sohn CLA 2021-02-23 18:59:21 EST
Please try again with nightly build. Now you should get error messages showing what's wrong in which file/line.
Comment 12 Thomas Wolf CLA 2021-03-03 03:41:34 EST
@Christoph: did you find the troublesome pattern? What was it?
Comment 13 Christoph Laeubrich CLA 2021-03-03 04:22:16 EST
@Thomas I'm currently a bit short on time to further investigate this but will try ASAP!
Comment 14 Thomas Wolf CLA 2021-05-22 04:35:01 EDT
Any update here?

Otherwise I'll close this as fixed, assuming it was a bad pattern in some .gitignore file, which the user should be able to find with the improved error messages.
Comment 15 Christoph Laeubrich CLA 2021-05-22 04:58:38 EDT
Yes this can be fixed I think, I haven't seen this error anymore in a while.
Comment 16 Christoph Laeubrich CLA 2021-09-16 03:53:54 EDT
I found the following today in my logs

File tests/org.eclipse.triquetrum.scisoft.analysis.rpc.test/.gitignore line 35: cannot parse pattern '.nfs[:xdigit:][:xdigit:][:xdigit:][:xdigit:][:xdigit:][:xdigit:][:xdigit:][:xdigit:]*': Not closed bracket?

the gitignore looks like this:
------------------------------------------
### Temporary files ###
*.bak
*.swp
*.tmp
*.*~

### Java ###
*.class
hs_err_pid*

### Python / Jython ###
__pycache__/
*.py[cod]
jythonCache/
cachedir/

### Build output ###
.springBeans
/bin/
/classes/
/src/corba/

### JUnit testing ###
/test-reports
/test-scratch

### Security files ###
*ssh.key
password
passwords

### Various OS, etc. files ###
*.lnk
desktop.ini
.nfs[:xdigit:][:xdigit:][:xdigit:][:xdigit:][:xdigit:][:xdigit:][:xdigit:][:xdigit:]*
.svn/
------------------------------------------

By the way it would be cool if such an error would be marked in the file itself (like compile-errors in java files) that would make locating malformed(?) entries much easier :-)
Comment 17 Thomas Wolf CLA 2021-09-21 09:38:44 EDT
(In reply to Christoph Laeubrich from comment #16)
> I found the following today in my logs
> 
> File tests/org.eclipse.triquetrum.scisoft.analysis.rpc.test/.gitignore line
> 35: cannot parse pattern
> '.nfs[:xdigit:][:xdigit:][:xdigit:][:xdigit:][:xdigit:][:xdigit:][:xdigit:][:
> xdigit:]*': Not closed bracket?

This pattern indeed is wrong; it should be [[:xdigit:]] instead of [:xdigit:].

The error message from JGit is a bit strange and not very helpful; I would have expected these malformed POSIX character classes to be taken as literal character sets equivalent to [dgitx:].

> By the way it would be cool if such an error would be marked in the file
> itself (like compile-errors in java files) that would make locating
> malformed(?) entries much easier :-)

Yes, but not doable without API breaks. Perhaps someone can come up with some way to improve error reporting for .gitignore and .gitattribute files for JGit 6.0. Markers would work in any case only if the .gitignore file was an Eclipse IResource (i.e., is in the Eclipse workspace), and .* resources are not filtered out.