homebridge / plugin-ui-utils

Create fully customisable configuration user interfaces for Homebridge plugins.
https://homebridge.io
MIT License
34 stars 7 forks source link

Unexpected token } #5

Closed ztalbot2000 closed 1 year ago

ztalbot2000 commented 3 years ago

In the basic server example I got the error message: xxxxx/homebridge-ui/server.js:44 } SyntaxError: Unexpected token '}'

The code actually corresponds to: // return data to the ui return { token: hashedUsername, }

As the only difference between your code and mine was some formatting from js-beautify. Clearly this is an error of the extra comma and I don't know why yours works out of the box.

bwp91 commented 1 year ago

Hi @ztalbot2000 Didn’t quite want to make it 2 years without a response on here 😝 Does this issue still have any relevance? cheers

ztalbot2000 commented 1 year ago

What? Really? I'll go poke now. Sorry

John

On Sat, Aug 12, 2023 at 6:17 PM Ben @.***> wrote:

Hi @ztalbot2000 https://github.com/ztalbot2000 Didn’t quite want to make it 2 years without a response on here 😝 Does this issue still have any relevance? cheers

— Reply to this email directly, view it on GitHub https://github.com/homebridge/plugin-ui-utils/issues/5#issuecomment-1676122956, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSBCX4XAFUUBLLS7Q34NETXU76HXANCNFSM5DCQY2AQ . You are receiving this because you were mentioned.Message ID: @.***>

bwp91 commented 1 year ago

Oh no if anything we have to be sorry for not getting to this issue sooner, no reason for you to be sorry!

ztalbot2000 commented 1 year ago

Hi Ben,

I don't know why Homebridge-Cmd4, My plugin was flagged for this. It seems to be just homebridge. I'm still looking.

On Sat, Aug 12, 2023 at 6:18 PM John Talbot @.***> wrote:

What? Really? I'll go poke now. Sorry

John

On Sat, Aug 12, 2023 at 6:17 PM Ben @.***> wrote:

Hi @ztalbot2000 https://github.com/ztalbot2000 Didn’t quite want to make it 2 years without a response on here 😝 Does this issue still have any relevance? cheers

— Reply to this email directly, view it on GitHub https://github.com/homebridge/plugin-ui-utils/issues/5#issuecomment-1676122956, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSBCX4XAFUUBLLS7Q34NETXU76HXANCNFSM5DCQY2AQ . You are receiving this because you were mentioned.Message ID: @.***>

ztalbot2000 commented 1 year ago

Hi, Hah, this is something I flagged homebridge for 2 years ago. I thought it was for my personal plugin Homebridge-Cmd4. It probably has not been rectified as there is a work around by removing the comma. Thankfully it is not against my plugin. I still have to leave this up to the homebridge people to fix. Sorry I cannot help you further.

John

On Sat, Aug 12, 2023 at 6:23 PM John Talbot @.***> wrote:

Hi Ben,

I don't know why Homebridge-Cmd4, My plugin was flagged for this. It seems to be just homebridge. I'm still looking.

On Sat, Aug 12, 2023 at 6:18 PM John Talbot @.***> wrote:

What? Really? I'll go poke now. Sorry

John

On Sat, Aug 12, 2023 at 6:17 PM Ben @.***> wrote:

Hi @ztalbot2000 https://github.com/ztalbot2000 Didn’t quite want to make it 2 years without a response on here 😝 Does this issue still have any relevance? cheers

— Reply to this email directly, view it on GitHub https://github.com/homebridge/plugin-ui-utils/issues/5#issuecomment-1676122956, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSBCX4XAFUUBLLS7Q34NETXU76HXANCNFSM5DCQY2AQ . You are receiving this because you were mentioned.Message ID: @.***>

bwp91 commented 1 year ago

I still have to leave this up to the homebridge people to fix.

I am 'the homebridge people' that's why i am responding on here

ztalbot2000 commented 1 year ago

Hi,

I assume if the code has not changed then it still does. I'll have to check if it still fails. I'll let you know.

Ttyl, John

On Sat, Aug 12, 2023 at 6:17 PM Ben @.***> wrote:

Hi @ztalbot2000 https://github.com/ztalbot2000 Didn’t quite want to make it 2 years without a response on here 😝 Does this issue still have any relevance? cheers

— Reply to this email directly, view it on GitHub https://github.com/homebridge/plugin-ui-utils/issues/5#issuecomment-1676122956, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSBCX4XAFUUBLLS7Q34NETXU76HXANCNFSM5DCQY2AQ . You are receiving this because you were mentioned.Message ID: @.***>

ztalbot2000 commented 1 year ago

Hi,

So I tried to recreate the issue and could not. Now that is not to say it is not incorrect as you are returning a JSON object that has a comma before the last closing brace which technically should not exist. My guess is that over the last two years an upgrade to nodejs has allowed this incorrect syntax. Either that or the Raspberry Pi I'm trying to recreate the issue on is not the iMac I originally issued the ticket for. Who knows? How you wish to handle this issue is now up to you.

ttyl, John

bwp91 commented 1 year ago

In your original comment where you references this javascript:

return
{
   token: hashedUsername,
}

don't get confused by javascript objects and JSON - the above code is perfectly valid js, and let's say we JSON.stringify()-ed this, the result would be:

{
   "token": "hashedUsername"
}

ie without the trailing comma.

So whatever the original issue is, not really sure, but if you aren't encountering this again, will go ahead and close this. of course, if you have any issues in the future please feel free to reopen this or create a new issue if unrelated 😁