Skip to content

Fix for "AttributeError: 'list' object has no attribute 'get'" in #281

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

Closed
wants to merge 1 commit into from

Conversation

hvanderheide
Copy link

StaticResolver

On success call_api() returns a list of dicts which StaticResolver
doesn't seem to expect. On failure just the single dict is returned.

StaticResolver

On success call_api() returns a list of dicts which StaticResolver
doesn't seem to expect. On failure just the single dict is returned.
@sgiehl sgiehl added this to the Current sprint milestone Oct 16, 2020
@diosmosis
Copy link
Member

This is currently tested via https://github.com/matomo-org/matomo/blob/4.x-dev/tests/PHPUnit/System/ImportLogsTest.php, I would expect the test to fail if this error was always the case. What version of Matomo / PHP / python are you using?

The result of SitesManager.getSiteFromId looks like this for me:

{'idsite': '1', 'name': 'Piwik test', 'main_url': 'http://piwik.net', 'ts_created': '2012-08-08 11:22:33', 'ecommerce': '0', 'sitesearch': '1', 'sitesearch_keyword_parameters': '', 'sitesearch_category_parameters': '', 'timezone': 'UTC', 'currency': 'USD', 'exclude_unknown_urls': '0', 'excluded_ips': '', 'excluded_parameters': '', 'excluded_user_agents': '', 'group': '', 'type': 'website', 'keep_url_fragment': '0', 'creator_login': 'superUserLogin', 'timezone_name': 'UTC', 'currency_name': 'US Dollar'}

(a dict, not a list)

@Prinzhorn
Copy link
Contributor

Prinzhorn commented Nov 9, 2020

I had to apply this fix for the script to run at all. I'm running an empty plain Matomo via the official docker-compose. Should make it easy to reproduce.

python3 import_logs.py \
  --url='http://localhost:8080' \
  --token-auth=1234 \
  --idsite=1 \
  --recorders=4 \
  log-file

@sgiehl
Copy link
Member

sgiehl commented Nov 18, 2020

@hvanderheide @Prinzhorn I assume you are both using the 4.x-dev branch of log-analytics with a Matomo 3.x release.
The response of SitesManager.getSiteFromId changed for Matomo 4. So when using Matomo 4 (which will be released soon), the log import should work without that fix.

@Prinzhorn
Copy link
Contributor

@sgiehl yes, it was just yesterday that I realized the default branch was configured to "4.x-dev". I just cloned the repo and started using it. Didn't realize the requirements said "Matomo >= 4.0.0". Actually I don't even know what Matomo version I'm using and that 4 isn't even released yet. I just fired up the docker-compose and started experimenting. Turns out I'm on the best version you'll probably ever release (3.14.1) unless you make it to 3.14.15

Could the very first step of the import script be to fetch the Matomo version and check if you're using the right script version?

@hvanderheide
Copy link
Author

@sgiehl thanks, until now I hadn't noticed. I'll close the PR

@innocraft-automation innocraft-automation removed this from the Current sprint milestone Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants