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

Column 'country_code' cannot be null #2526

Open
xanathon opened this issue Jun 4, 2019 · 10 comments

Comments

Projects
None yet
5 participants
@xanathon
Copy link

commented Jun 4, 2019

I get the feedback from some users that urls do not work and generate the following error:

Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'country_code' cannot be null in /www/htdocs/w01882f8/pnde/includes/vendor/aura/sql/src/ExtendedPdo.php:748 Stack trace: #0 /www/htdocs/w01882f8/pnde/includes/vendor/aura/sql/src/ExtendedPdo.php(748): PDOStatement->execute() #1 /www/htdocs/w01882f8/pnde/includes/vendor/aura/sql/src/ExtendedPdo.php(306): Aura\Sql\ExtendedPdo->perform('INSERT INTO yo...', Array) #2 /www/htdocs/w01882f8/pnde/includes/functions.php(897): Aura\Sql\ExtendedPdo->fetchAffected('INSERT INTO yo...', Array) #3 /www/htdocs/w01882f8/pnde/includes/functions.php(740): yourls_log_redirect('o') #4 /www/htdocs/w01882f8/pnde/yourls-go.php(21): yourls_redirect_shorturl('https://phantan...', 'o') #5 /www/htdocs/w01882f8/pnde/yourls-loader.php(37): require_once('/www/htdocs/w01...') #6 {main} thrown in /www/htdocs/w01882f8/pnde/includes/vendor/aura/sql/src/ExtendedPdo.php on line 748

This seems to be the case on iOs and Safari, but also on some instances of Firefox on Windows. Probably caused by some anti-tracking solution blocking the users country in some referral.

For most users this works, but I got multiple reports of this proiblem today for the url

http://pnde.eu/o

What can be the problem? Thanks in advance.

Edit: I see that Facebook crippled the error message, I will try to get a complete one and add it here.

@xanathon xanathon added the bug label Jun 4, 2019

@Ryfter

This comment has been minimized.

Copy link

commented Jun 12, 2019

I just had a user tell me this, too. It'd be nice to log this, and not have it spew it for anyone to see. :-)

What I was told:

"Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'country_code' cannot be null"

I'm running 1.7.3.

@ozh

This comment has been minimized.

Copy link
Member

commented Jun 12, 2019

Hi. First, we need to have a reproducible way to generate this error. Otherwise, we won't be able to check if a solution really fixes it.
I know it may be hard to pin point, but this is really the first step not to see an issue closed with "Works for me" :)

@spyjo

This comment has been minimized.

Copy link

commented Jun 12, 2019

I already had the same problem, sometimes yourls_geo_ip_to_countrycode() is returning null or empty value, when the Maxmind db has no information on the user IP address. So the INSERT query in yourls_log_redirect() function is failing.

@xanathon

This comment has been minimized.

Copy link
Author

commented Jun 13, 2019

You guys are funny. How can I - in your opinion - reproduce an error that I do not get, but multiple users reported? Those are not techheads but simple users that just want a working link.

The error message seems to be somewhat helpful for me. The code tries to insert something into the column country_code but cannot. Since I do not know the code I can only presume that is to fill the statistics (that are probably not GDPR compliant anyway), but cannot, e.g. if the user has blocking mechanisms for such tracking.

This seems to happen more often under iOS and Mac OS.

"Works for me" is a quite bad answer form any support. As that does not address the problem and does not help the users in any way. There IS an error message that should at least give hints where to insert a workaround.

Thanks.

@Ryfter

This comment has been minimized.

Copy link

commented Jun 13, 2019

I'm thinking what may be causing it, is the client isn't sending all the details, like country code for whatever reason. I'd be happy to pass the user through and not get the error but log it. It blows up, and thst can be a security concern.

@ozh

This comment has been minimized.

Copy link
Member

commented Jun 14, 2019

@xanathon : just to clear something: ""Works for me" is a quite bad answer form any support." : there is no "support" provided. Volunteer free time as available, at best. This is free software with no guarantee of it working or it being fixed when someone encounters an error.

@xanathon

This comment has been minimized.

Copy link
Author

commented Jun 15, 2019

I'm totally clear how open software works. However, if you provide the possibility to report issues here on GitHub there should be someone who addresses those or do not offer the possibility and state so clearly on the YOURLS website. On that website the impression is given, that this is a somewhat professional endeavour and the use is encouraged with words one could see as advertising.

If there are gamebreaking errors and those are probably not addressed, the users need to know that before using the software so they can probably choose another solution. Changing to another solution after encountering errors is very cumbersome.

Thanks for your work.

@dgw

This comment has been minimized.

Copy link
Member

commented Jun 15, 2019

FWIW, in almost 8 years of using YOURLS (since long before I was invited to join the project), I have never seen this error. We ask for reproduction steps because we can't figure out how to trigger the bug ourselves—and without that knowledge, it is very hard to even start working on a fix, because we can't test it.

@xanathon

This comment has been minimized.

Copy link
Author

commented Jun 15, 2019

As I said above. The error message was reported by multiple users on Win/Chrome, iOS and Mac OS. Those users are not tech-savvy enough to help. But they did provide that error message.

I do not know your code, but it seems obvious to me that some values cannot be inserted into a mySQL table because those are missing. To me it clearly looks like there are tracking countermeasures at work that lead to missing data like country of origin and that leads to an uncaught exception. I can not know where you do such things in your code (but I guess it is for statistics), so I have no idea where to look.

One way to resolve this could be to give admins the option to switch off statistics (besides clicks) as it is highly problematic due to gdpr anyway. ATM I have to change the code to prevent YOURLS to log IP addresses together with other statistics.

So: Yes, I know that it is difficult to find an error you can not reproduce, but it is there anyway - and there seem logical causes for this error that could lead to a solution. One of them could be to get rid of user statistics.

@ozh

This comment has been minimized.

Copy link
Member

commented Jun 15, 2019

No sweat. Most likely, the ip 2 country stuff has changed something on their end that causes null return. Probably all we need to do is make sure it always return something not null. Too bad we won't be able to check if that fixes the problem for those who encountered.

Next time someone gets a report from their user, please ask detail to them : their IP, the short URL requested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.