Error against mysql.persist in Visual Studio Code

I’ve recently been directed to use Visual Studio Code for editing my files, and it has been a game changer!

However, when it loads I get 2 errors listed at the bottom in relation to my mysql.persist file:

mismatched input 'default' expecting RULE_ID
no viable alternative at input 'restoreOnStartup'

and the content of my persist file:

Strategies {
    everyMinute     : "0 * * * * ?"
    everyHour       : "0 0 * * * ?"
    everyDay        : "0 0 0 * * ?"
    default = everyChange
}

Items {
    gAllLights*  : strategy = everyChange, restoreOnStartup
    gChart*  : strategy = everyMinute, restoreOnStartup
    gHistory*  : strategy = everyChange, restoreOnStartup
}

My data is, and has always been, persisting correctly and all my charts are as expected so the file seems to be working OK.

Can anyone advise?

Do you have a rule file named default?

Nope, not that I can see anyway!

Try: default = everyUpdate

Edit: use everyUpdate if using mapdb as persist.

Still the same with everyUpdate.

As I say everything is working as expected, so maybe this is just a case of not broken don’t touch it, but if there is a way to just clear the error would be good.

I do not use mysql but most will recommend to use mapdb for restore on start up. Maybe try removing restoreOnStartup from mysql and add mapdb. You can keep mysql for all other persist needs.

Strategies {
  default = everyUpdate
}

Items {
  item1, item2 : strategy = everyChange, restoreOnStartup
}

Could you post the complete errors? That way we would also know where the errr occurs (line, column).

Sure

{
	"resource": "/etc/openhab2/services/mysql.persist",
	"owner": "_generated_diagnostic_collection_name_#0",
	"code": "org.eclipse.xtext.diagnostics.Diagnostic.Syntax",
	"severity": 8,
	"message": "mismatched input 'default' expecting RULE_ID",
	"startLineNumber": 6,
	"startColumn": 20,
	"endLineNumber": 6,
	"endColumn": 27
}

and

{
	"resource": "/etc/openhab2/services/mysql.persist",
	"owner": "_generated_diagnostic_collection_name_#0",
	"code": "org.eclipse.xtext.diagnostics.Diagnostic.Syntax",
	"severity": 8,
	"message": "no viable alternative at input 'restoreOnStartup'",
	"startLineNumber": 6,
	"startColumn": 29,
	"endLineNumber": 6,
	"endColumn": 45
}

Which is even more confusing, as line 6 is just the closing bracket after the strategies, there are no empty spaces after the bracket.

Since your persistence rules work as far as OH is concerned, and your persistence file matches quite closely with my mysql persistence file which does not produce any errors it sounds like the issue must be in VSC somewhere.

Are you using the OH plugin for VSC? If so, which version?

Reckon you’ve got some hidden control characters in there.

Well, I don’t know what happened, but the error is no longer flagging!

Thanks all for your inputs

glad you got it fixed.

I would recomend like @H102 to use the mapdb persistance for restore on startup.

My mapdb.persist file

Strategies {
	default = everyChange
}
Items {
	* : strategy = everyChange, restoreOnStartup
}