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

Repair not raised for MarketingConsentError #587

Open
WebSpider opened this issue Jan 25, 2025 · 18 comments
Open

Repair not raised for MarketingConsentError #587

WebSpider opened this issue Jan 25, 2025 · 18 comments
Labels
bug Something isn't working

Comments

@WebSpider
Copy link
Contributor

Hello!

Apologies for bringing this issue up again. I’ve installed the latest version 1.19.1, and when I enter my email and password, I encounter an error. The logs provide the following details:

This error originated from a custom integration

Logger: custom_components.myskoda.config_flow  
Source: custom_components/myskoda/config_flow.py:111  
Integration: MySkoda (Documentation, Issues)  
First occurred: January 24, 2025, 23:58:02 (3 occurrences)  
Last logged: 00:04:05  

Unexpected exception  
Traceback (most recent call last):  
  File "/config/custom_components/myskoda/config_flow.py", line 111, in async_step_user  
    await validate_input(self.hass, user_input)  
  File "/config/custom_components/myskoda/config_flow.py", line 67, in validate_input  
    await hub.connect(data["email"], data["password"])  
  File "/usr/local/lib/python3.13/site-packages/myskoda/myskoda.py", line 130, in connect  
    await self.authorization.authorize(email, password)  
  File "/usr/local/lib/python3.13/site-packages/myskoda/auth/authorization.py", line 77, in authorize  
    self.idk_session = await self._get_idk_session()  
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
  File "/usr/local/lib/python3.13/site-packages/myskoda/auth/authorization.py", line 224, in _get_idk_session  
    authentication = await self._enter_password(login_meta)  
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
  File "/usr/local/lib/python3.13/site-packages/myskoda/auth/authorization.py", line 167, in _enter_password  
    raise MarketingConsentError(location)  
myskoda.auth.authorization.MarketingConsentError: https://identity.vwgroup.io/signin-service/v1/consent/marketing/be678393-faec-4452-aee3-61d2911f6acf/7f045eee-7003-4379-9968-9355ed2adb06@apps_vw-dilab_com/0?relayState=138519ce24b449a4cde904e85170a8923278f405&hmac=5195dc33b3ceb6d09b1833737171335e1a0c7e22dccf99ad4e2a6e40921420e4&callback=https://identity.vwgroup.io/oidc/v1/oauth/client/callback/success?user_id%3Dbe678393-faec-4452-aee3-61d2911f6acf%26client_id%3D7f045eee-7003-4379-9968-9355ed2adb06@apps_vw-dilab_com%26scopes%3Daddress%2520badge%2520birthdate%2520cars%2520driversLicense%2520dealers%2520email%2520mileage%2520mbb%2520nationalIdentifier%2520openid%2520phone%2520profession%2520profile%2520vin%26consentedScopes%3Daddress%2520badge%2520birthdate%2520cars%2520driversLicense%2520dealers%2520email%2520mileage%2520mbb%2520nationalIdentifier%2520openid%2520phone%2520profession%2520profile%2520vin%26relayState%3D138519ce24b449a4cde904e85170a8923278f405%26hmac%3Dba9d95aa379a1dbef19f6986e4bc714c982f3c559f16c32dc30c1c51b1bcff16  

Am I doing something wrong?

Thank you!

Originally posted by @UZi02 in #453 (comment)

@WebSpider WebSpider added the bug Something isn't working label Jan 25, 2025
@firebirder78
Copy link

Hi,

I also encountered the same issue when upgrading the integration.
I found a workaround that solved it for me.
I copied the full (lengthy) URL presented in the logs just like in yours starting with https://identity.vwgroup.io/signin-service/v1/consent/marketing/...
It opened a website where Skoda is asking your permission to reach out to you for marketing purposes. I just clicked on "no" a few times (don't remember exactly what the options were). After 3-4 clicks it opened the MySkoda app on my smartphone and logged in.
After a restart of HA, the integration worked fine again.
Let us know if this helped you as well.

Sascha

@Schlichi83
Copy link

Schlichi83 commented Jan 29, 2025

I have the same issue. Workaround doesn't help:

Logger:` custom_components.myskoda.coordinator
Quelle: helpers/update_coordinator.py:379
Integration: MySkoda (Dokumentation, Probleme)
Erstmals aufgetreten: 11:55:10 (9 Vorkommnisse)
Zuletzt protokolliert: 11:58:24

Unexpected error fetching myskoda data
Traceback (most recent call last):
  File "<string>", line 8, in __mashumaro_from_dict_json__
  File "/usr/local/lib/python3.13/enum.py", line 726, in __call__
    return cls.__new__(cls, value)
           ~~~~~~~~~~~^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/enum.py", line 1199, in __new__
    raise ve_exc
ValueError: 'MARKETING_CONSENT_SAD' is not a valid UserCapabilityId

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 10, in __mashumaro_from_json__
  File "<string>", line 10, in __mashumaro_from_dict_json__
mashumaro.exceptions.InvalidFieldValue: Field "id" of type UserCapabilityId in UserCapability has invalid value 'MARKETING_CONSENT_SAD'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 379, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/myskoda/coordinator.py", line 174, in _async_update_data
    user = await self.myskoda.get_user()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/myskoda/myskoda.py", line 364, in get_user
    return (await self.rest_api.get_user(anonymize=anonymize)).result
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/myskoda/rest_api.py", line 270, in get_user
    result = self._deserialize(raw, User.from_json)
  File "/usr/local/lib/python3.13/site-packages/myskoda/rest_api.py", line 602, in _deserialize
    data = deserialize(text)
  File "<string>", line 12, in __mashumaro_from_json__
mashumaro.exceptions.InvalidFieldValue: Field "capabilities" of type list[UserCapability] in User has invalid value [{'id': 'SPIN_MANAGEMENT'}, {'id': 'THIRD_PARTY_OFFERS'}, {'id': 'MARKETING_CONSENT'}, {'id': 'MARKETING_CONSENT_SAD'}, {'id': 'MARKETING_CONSENT_SAD_THIRD_PARTY'}, {'id': `'MARKETING_CONSENT_SAD_DEALERS'}]

@miczu71
Copy link

miczu71 commented Jan 29, 2025

I'm having the same issue now as above user:

Traceback (most recent call last):
  File "<string>", line 8, in __mashumaro_from_dict_json__
  File "/usr/local/lib/python3.13/enum.py", line 726, in __call__
    return cls.__new__(cls, value)
           ~~~~~~~~~~~^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/enum.py", line 1199, in __new__
    raise ve_exc
ValueError: 'MARKETING_CONSENT_GENERIC' is not a valid UserCapabilityId

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 10, in __mashumaro_from_json__
  File "<string>", line 10, in __mashumaro_from_dict_json__
mashumaro.exceptions.InvalidFieldValue: Field "id" of type UserCapabilityId in UserCapability has invalid value 'MARKETING_CONSENT_GENERIC'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/myskoda/rest_api.py", line 602, in _deserialize
    data = deserialize(text)
  File "<string>", line 12, in __mashumaro_from_json__
mashumaro.exceptions.InvalidFieldValue: Field "capabilities" of type list[UserCapability] in User has invalid value [{'id': 'SPIN_MANAGEMENT'}, {'id': 'THIRD_PARTY_OFFERS'}, {'id': 'MARKETING_CONSENT'}, {'id': 'MARKETING_CONSENT_GENERIC'}]

@Tanfoglio
Copy link

Tanfoglio commented Jan 29, 2025

Same here.
The integration stopped working a few hours ago and I'm seeing similar error messages as above.
However, I can't find an exact URL to try the workaround as described by @firebirder78 .

Using version 1.18.1.

@FxQt
Copy link

FxQt commented Jan 29, 2025

Report the same issue for version 1.17.1 and 1.19.1.

Log files are the same as @Schlichi83 and @miczu71 posted.

@korttoma
Copy link

Same here on 1.18.1

@ric866
Copy link

ric866 commented Jan 29, 2025

Hi All,

First issue post here, so please be gentle.

I think there are two issues being discussed here - the first (and opening issue) may or may not be related, but looks like a consent issue, where-as my (and the subsequent) issues are seemingly a change to the API responses. So apologies for not opening a new issue here.

I have the described error showing up since 10:18 today (mashumaro.exceptions.InvalidFieldValue: Field "id" of type UserCapabilityId in UserCapability has invalid value 'MARKETING_CONSENT_GENERIC')

The problem seems to be a new id capability being returned by the API, which is not handled well by the data parser.

I've made a fix in my local install, and went into my skoda app and slid the slider under Profile -> Permissions & Consent -> Access to Vehicle data (though that might not be related) and things seem to be working again :
/usr/local/lib/python3.13/site-packages/myskoda/models/user.py

class UserCapabilityId(StrEnum):
    SPIN_MANAGEMENT = "SPIN_MANAGEMENT"
    THIRD_PARTY_OFFERS = "THIRD_PARTY_OFFERS"
    MARKETING_CONSENT = "MARKETING_CONSENT"
    TEST_DRIVE = "TEST_DRIVE"

Becomes


class UserCapabilityId(StrEnum):
    SPIN_MANAGEMENT = "SPIN_MANAGEMENT"
    THIRD_PARTY_OFFERS = "THIRD_PARTY_OFFERS"
    MARKETING_CONSENT = "MARKETING_CONSENT"
    TEST_DRIVE = "TEST_DRIVE"
    MARKETING_CONSENT_GENERIC = "MARKETING_CONSENT_GENERIC"

Restart Hassio, and the API seems to work again.

If I could find this file in the repo, I would make a pull request :)

@plaiddk
Copy link

plaiddk commented Jan 29, 2025

Hi All,

First issue post here, so please be gentle. I have this same issue (mashumaro.exceptions.InvalidFieldValue: Field "id" of type UserCapabilityId in UserCapability has invalid value 'MARKETING_CONSENT_GENERIC')

The problem seems to be a new id capability being returned by the API, which is not handled well by the data parser.

I've made a fix in my local install and things seem to be working again : /usr/local/lib/python3.13/site-packages/myskoda/models/user.py

class UserCapabilityId(StrEnum):
    SPIN_MANAGEMENT = "SPIN_MANAGEMENT"
    THIRD_PARTY_OFFERS = "THIRD_PARTY_OFFERS"
    MARKETING_CONSENT = "MARKETING_CONSENT"
    TEST_DRIVE = "TEST_DRIVE"

Becomes


class UserCapabilityId(StrEnum):
    SPIN_MANAGEMENT = "SPIN_MANAGEMENT"
    THIRD_PARTY_OFFERS = "THIRD_PARTY_OFFERS"
    MARKETING_CONSENT = "MARKETING_CONSENT"
    TEST_DRIVE = "TEST_DRIVE"
    MARKETING_CONSENT_GENERIC = "MARKETING_CONSENT_GENERIC"

Restart Hassio, and the API seems to work again.

If I could find this file in the repo, I would make a pull request :)

Where do you change this in HomeAssistant?

@ric866
Copy link

ric866 commented Jan 29, 2025

Hi All,
First issue post here, so please be gentle. I have this same issue (mashumaro.exceptions.InvalidFieldValue: Field "id" of type UserCapabilityId in UserCapability has invalid value 'MARKETING_CONSENT_GENERIC')
The problem seems to be a new id capability being returned by the API, which is not handled well by the data parser.
I've made a fix in my local install and things seem to be working again : /usr/local/lib/python3.13/site-packages/myskoda/models/user.py

class UserCapabilityId(StrEnum):
    SPIN_MANAGEMENT = "SPIN_MANAGEMENT"
    THIRD_PARTY_OFFERS = "THIRD_PARTY_OFFERS"
    MARKETING_CONSENT = "MARKETING_CONSENT"
    TEST_DRIVE = "TEST_DRIVE"

Becomes


class UserCapabilityId(StrEnum):
    SPIN_MANAGEMENT = "SPIN_MANAGEMENT"
    THIRD_PARTY_OFFERS = "THIRD_PARTY_OFFERS"
    MARKETING_CONSENT = "MARKETING_CONSENT"
    TEST_DRIVE = "TEST_DRIVE"
    MARKETING_CONSENT_GENERIC = "MARKETING_CONSENT_GENERIC"

Restart Hassio, and the API seems to work again.
If I could find this file in the repo, I would make a pull request :)

Where do you change this in HomeAssistant?

I made this change on the command line in Home Assistant, in the file I mentioned. I would advise caution, as making a bad change here could have non-start consequences for Hassio.

As per normal, create a good copy of the file and take care (especially if you're using vi).

@ric866
Copy link

ric866 commented Jan 29, 2025

And as if the plea's for help were heard by @WebSpider (Thank you Webspider!) the non-original issue is already fixed in the underlying code, so I am sure will make it's way through the update channels shortly.

skodaconnect/myskoda@4631cc0

@WebSpider
Copy link
Contributor Author

I'm having the same issue now as above user:

Traceback (most recent call last):
  File "<string>", line 8, in __mashumaro_from_dict_json__
  File "/usr/local/lib/python3.13/enum.py", line 726, in __call__
    return cls.__new__(cls, value)
           ~~~~~~~~~~~^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/enum.py", line 1199, in __new__
    raise ve_exc
ValueError: 'MARKETING_CONSENT_GENERIC' is not a valid UserCapabilityId

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 10, in __mashumaro_from_json__
  File "<string>", line 10, in __mashumaro_from_dict_json__
mashumaro.exceptions.InvalidFieldValue: Field "id" of type UserCapabilityId in UserCapability has invalid value 'MARKETING_CONSENT_GENERIC'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/myskoda/rest_api.py", line 602, in _deserialize
    data = deserialize(text)
  File "<string>", line 12, in __mashumaro_from_json__
mashumaro.exceptions.InvalidFieldValue: Field "capabilities" of type list[UserCapability] in User has invalid value [{'id': 'SPIN_MANAGEMENT'}, {'id': 'THIRD_PARTY_OFFERS'}, {'id': 'MARKETING_CONSENT'}, {'id': 'MARKETING_CONSENT_GENERIC'}]

This will be fixed in 1.19.2, awaiting code review now.

@Tanfoglio
Copy link

Wow, talking a bout a fast fix. Great job guys!

Does anyone have a suggestion on how we can fix this locally without upgrading? I can't seem to find the user.py file on my HA OS...
I've not been able to upgrade Home Assistant to 2025.1 because of modbus issues, so MySkoda 1.19 is also not an option for now.

Thanks for the help!

@WebSpider
Copy link
Contributor Author

WebSpider commented Jan 29, 2025

Wow, talking a bout a fast fix. Great job guys!

Does anyone have a suggestion on how we can fix this locally without upgrading? I can't seem to find the user.py file on my HA OS...
I've not been able to upgrade Home Assistant to 2025.1 because of modbus issues, so MySkoda 1.19 is also not an option for now.

Thanks for the help!

It is in the myskoda library, not in the integration, not so easy to find.

You can force the upgrade by changing myskoda==0.17.x to 0.18.1 in manifest.json

@WebSpider
Copy link
Contributor Author

I have the same issue. Workaround doesn't help:

Logger:` custom_components.myskoda.coordinator
Quelle: helpers/update_coordinator.py:379
Integration: MySkoda (Dokumentation, Probleme)
Erstmals aufgetreten: 11:55:10 (9 Vorkommnisse)
Zuletzt protokolliert: 11:58:24

Unexpected error fetching myskoda data
Traceback (most recent call last):
  File "<string>", line 8, in __mashumaro_from_dict_json__
  File "/usr/local/lib/python3.13/enum.py", line 726, in __call__
    return cls.__new__(cls, value)
           ~~~~~~~~~~~^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/enum.py", line 1199, in __new__
    raise ve_exc
ValueError: 'MARKETING_CONSENT_SAD' is not a valid UserCapabilityId

Thanks for this detail, I will add it to the next release as well.

@WebSpider
Copy link
Contributor Author

WebSpider commented Jan 29, 2025

v1.19.2 has been released. which should fix the errors named in #598 and MARKETING_CONSENT_GENERIC as well.

@Tanfoglio
Copy link

It is in the myskoda library, not in the integration, not so easy to find.

You can force the upgrade by changing myskoda==0.17.x to 0.18.1 in manifest.json

This did the trick.
Everything is working again now.
Thanks a lot!

@PottiMc
Copy link

PottiMc commented Jan 30, 2025

1.19.2 worked for me too. Thank you for that fix!

@CBxGBG
Copy link

CBxGBG commented Jan 30, 2025

Would it be possible to push v1.19..2 as a nor mal update please?
That will help most users to resolve their issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests