HPM, Hub Security Enabled, Files Not Copied Successfully

@csteele
I believe I saw somewhere you were maintaining HPM. Thank you!!
I am using HPM to distribute an app, which includes two files needing to be written to the file manager (js and css), in order to work properly.

There have been two situations where a user has informed me it is not working correctly. After some debugging; I determined the js and css files were not located in the file manager.

One thing in common between these two users are they both have Hub Security enabled.

My questions:

  1. Have you heard of anything like this before? Is there something I may have done incorrectly in my code? (It works fine when security is not enabled)
  2. The most recent user reporting this issue; said the HPM page for installing my app said the two files were copied successfully (even though they were not).

More information here (last few posts):

Thanks for your time!

I have login security (no SSL) and just deleted those two files then ran a repair, it worked fine.

They should turn on debug logging (in HPM settings) and try a repair, see what logs shows.

Also in HPM go to Settings and make sure the Hub Login security part is setup correctly.

image

@csteele what does it even use the login security for still? If everything is via endpoints there are (easy) ways now where that can all be done without the login credentials. I have done that in my SmartStart app which writes to the file manager and uses some other endpoints. Also Hub Info driver eliminated the need for the login as well. I know you don't want to make too many changes to the app since it works as-is, but something to consider for future.

Thanks so much for the pointers!
I think this is a perfect opportunity to dust off the dev hub, and try to replicate this myself.
Good to know about the HPM logs, thanks for that.
Also completely understand about not wanting to change something that isn't necessarily broken.

I'll post back with my results.

Believe he is looking at that, the question being whether he needs to retain it for backward compatibility.

I agree that the latest Platform + latest HPM no longer need Hub Security to match to work, but, as @thebearmay points out, it may be wise to leave it since, as far as I know, sending the credentials doesn't break it. And if ever the Platform did reject valid credentials, that sounds like a bug from my point of view :smiley: Which means HPM's hub security settings need to be blank to take advantage of the Platform. I would expect the Platform to either ignore the credentials (first choice) or accept either blank or correct credentials. Invalid credentials could lead to an error. (second choice)

1 Like

I'm seeing this in my logs when I attempt to install your Package on an otherwise empty C-8 Pro:

app:2 2025-01-17 07:34:38.599 AM info  Fatal error occurred, rolling back
app:2 2025-01-17 07:34:37.979 AM info  Installing Rule Machine Manager
app:2 2025-01-17 07:34:37.923 AM info  Downloading Rule Machine Manager
app:2 2025-01-17 07:34:37.869 AM info  Downloading https://raw.githubusercontent.com/joshlobe/hubitat/main/rule_machine_manager/rule_machine_manager.css
app:2 2025-01-17 07:34:37.771 AM info  Downloading https://raw.githubusercontent.com/joshlobe/hubitat/main/rule_machine_manager/rule_machine_manager.js
app:2 2025-01-17 07:34:37.568 AM debug Install beginning
app:2 2025-01-17 07:34:37.566 AM debug prefInstall
app:2 2025-01-17 07:34:35.444 AM debug prefInstallVerify
app:2 2025-01-17 07:34:32.339 AM debug prefInstallChoices
app:2 2025-01-17 07:34:28.865 AM debug prefInstallRepositorySearchResults
app:2 2025-01-17 07:34:24.453 AM debug prefInstallRepositorySearch
app:2 2025-01-17 07:34:23.236 AM debug prefPkgInstall

Yep.. I was able to replicate on my dev C-7.
Any idea what's up with that?
If you go to the url manually, you'll see the groovy file.

Here is my package manifest file:

{
	"packageName": "Rule Machine Manager",
	"minimumHEVersion": "2.3.5.152",
	"author": "Josh Lobe",
	"documentationLink": "https://github.com/joshlobe/hubitat",
	"communityLink": "https://community.hubitat.com/t/initial-release-rule-machine-manager-new-rule-machine-interface",
	"version": "1.1.4",
	"dateReleased": "2023-10-04",
	"licenseFile": "",
	"tags": "Rule Machine",
	"releaseNotes": "1.1.4 - View full changelog here: https://raw.githubusercontent.com/joshlobe/hubitat/main/rule_machine_manager/changelog.txt",
	"apps" : [
		{
			"id" : "6wjv6vft-geb7-n2ex-rq4c-vvd32wqw4379",
			"name": "Rule Machine Manager",
			"namespace": "ruleMachineManager",
			"location": "https://raw.githubusercontent.com/joshlobe/hubitat/main/rule_machine_manager/rule_machine_manager.groovy",
			"required": true,
			"oauth": false,
			"description": "Manage rules more intuitively with custom sorting and custom groups."
		}
	],
	"files" : [
		{
			"id" : "45hfo4gy-fd83-8v7e-fed6-vhe34jfu4b56",
			"name" : "rule_machine_manager.js",
			"location" : "https://raw.githubusercontent.com/joshlobe/hubitat/main/rule_machine_manager/rule_machine_manager.js"
		},
		{
			"id" : "pefber8j-fd9r-snv0-ddr9-vhe98f7e9dv3",
			"name" : "rule_machine_manager.css",
			"location" : "https://raw.githubusercontent.com/joshlobe/hubitat/main/rule_machine_manager/rule_machine_manager.css"
		}
	]
}

For quite a while now, I've had a development version of HPM that is full of debugging logs and uses a highly custom repository. I copied all of your files to my debugging repo and ran a handful of tests.

First step was to verify that using the debugging repo behaved the same, indicating it's ready to start with the debugging. It was and my first test was to alter the Package Manifest to be just the Groovy file, eliminating the file manager portion. Indeed that failed as predicted. Then to be sure, I reversed it, and made the Package Manifest only the file manager pair. Those worked as expected. (Expected, because the error message seems to be appearing at the beginning, not the end of the list of 3 files.)

I then reverted to v2.3.9 and ran the 'just groovy' install again. It failed too, so it's not a new change to the Platform causing this, unfortunately. I've put my test environment back to the latest platform and tested once more and got the same error (on just the groovy file.)

What I cannot fathom at this moment is how it's "bad" today all of a sudden. Both HPM and your Package are relatively old (in computer minutes :slight_smile: ) and the install fails independent of platform.

Not an important test, but when I was installing just the file manager pair of files, they not only installed, but repaired and uninstalled flawlessly.

IF I find out more, I'll say so....

2 Likes

That is the most lucid, intelligent, well-thought-out response I've ever heard in my life! All I can say, is thank you!

I've also taken the HPM package and installed on my dev hubitat.
I'm adding logs here and there, and trying to at least identify what exactly is failing.
So far I've found nothing... but I'm not done looking.

I certainly appreciate your assistance!

1 Like

Have you tested just importing the code directly on the app code page?

2 Likes

Import fails and copy paste of the groovy code won't save:

Screenshot 2025-01-18 at 4.23.16 PM

Using a slash-and-burn technique, if I eliminate the code between:
/**************************************************
// Page options panel
/
and:
/

// Page containers
**************************************************/
It will compile and save.

eliminating that one line (#228) allows it to compile and save.

Modifying the code in my private repository, then using HPM to install the entire Package, works. I can't see anything explicitly wrong with that line at first glance.

Screenshot 2025-01-18 at 4.41.21 PM

5 Likes

My gosh, you two are simply amazing!!
I never thought of attempting to paste/save and troubleshoot from there.

The issue is the substring. If the user is installing my app; and has not yet created any rules using Rule Manager.. than resetRules will be an empty array... which makes default_rules not contain any commas. Taking lastIndexOf(',') on a string with no commas will generate -1. The issue is then trying to use substring(0, -1) which generates an "out of bounds" exception.

Anyways, wrapping lines 227 and 228 with an if (resetRules) conditional fixes the issue and I can save the app.

Thank you! Thank you!
It would have taken me years to find this on my own :slight_smile:

4 Likes

I started from an "empty" Hub (freshly Full Reset) and thus I don't even have RM installed :smiley: It comes only with Basic Rules. That means I was the ideal case to reproduce it. :slight_smile:

4 Likes

Indeed you were.
Seriously, a millions thanks!

1 Like