-
Notifications
You must be signed in to change notification settings - Fork 399
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
REST API: Incoherent /search result #1481
Comments
OK, this is driving me mad. fossology/src/www/ui/api/Helper/DbHelper.php Line 104 in e326309
Any help, at least to reproduce is welcome :-) In this function, we build a SQL query to retrieve the uploads with the correct UserID and UploadID.
The problem:
Now, if I force the So the incoherent result only happen when building the SQL query using the input variable. Same story with logs:
|
It turns out that only the first query is properly executed - and result is somehow "reused" for following queries. If I execute a random query with
Gives
|
Hi , I managed to find cause of those incorrect results. Problem sits in src/www/ui/api/Helper/DbHelper/getUpload() method
Inside getUpload method there is SELECT statement preparation (result can vary depending on parameters passed) and invokation of dbManager.getRows() method, but with only one parameter called $sqlStatement
And here comes the problem: When there is another call form the same class::method pair, this caching mechanism uses and executes previously cached preparedStatement. There is no verification if new $sqlStatement is same with version stored in previously created preparedStatement That's why Nicolas each time gets results for first query used in first getRows() method invocation. To solve this issue, in src/www/ui/api/Helper/DbHelper/getUpload() we should prepare our own $statementName and pass it while invoking getRows() method. It could be something like: What do you think about this? As an alternative, we might consider changing this preparedStatement mechanism and change default statementName generation to contain sort of sqlStatement hash. |
I found a better solution instead of creating $statementName with parameters values in it - I will reuse $params[] array to pass parameters to getRows() method (same as it is in DbHelper/getUsers() method) I will create a PR for this change as it is quite crucial for us |
Queries like the following Were working fine when using fossology 3.11.0. In order to try solving another problem, I upgraded fossology to 4.2.1.
Is search function of REST API supposed to work with fossology 4.2.1 ? |
@YanickNoblanc that's not supposed to happen. Can you please share your error.log file? |
Hi,
Thanks for your quick reaction.
Content of /var/log/apache2/error.log
[Fri Mar 10 16:09:15.454221 2023] [php7:warn] [pid 30399] [client 10.124.177.104:62017] PHP Warning: require_once(/usr/share/fossology/www/ui/search-helper.php): failed to open stream: No such file or directory in /usr/share/fossology/www/ui/api/Controllers/SearchController.php on line 23
[Fri Mar 10 16:09:15.454340 2023] [php7:error] [pid 30399] [client 10.124.177.104:62017] PHP Fatal error: require_once(): Failed opening required '/usr/share/fossology/www/ui/search-helper.php' (include_path='.:/usr/share/php') in /usr/share/fossology/www/ui/api/Controllers/SearchController.php on line 23
Cordialement
Yanick Noblanc
Responsible Integration Continue | CETX |
P. +33 (0)1 30 20 26 02
E. ***@***.******@***.***>
18, Chaussé Jules César
95520 Osny
[Idemia]<https://www.idemia.com/>
Join us on
[Facebook]<https://urldefense.proofpoint.com/v2/url?u=https-3A__www.facebook.com_IdemiaGroup_&d=DwMGaQ&c=znOEDNGT1crOtqImlna_pg&r=aFahRJmcW_kqFPEhKEJYOH6InoYTcYsaDFJJXjqEk4o&m=sQ95yL3bygza_y3ep6yG_dIulPTj0BV5AJQGTJrrkVw&s=TaIyFDPbR-6BYF5TZRJvcUE7OTbs_J7hd7Uwjur5yms&e=>
[Twitter]<https://urldefense.proofpoint.com/v2/url?u=https-3A__twitter.com_IdemiaGroup&d=DwMGaQ&c=znOEDNGT1crOtqImlna_pg&r=aFahRJmcW_kqFPEhKEJYOH6InoYTcYsaDFJJXjqEk4o&m=sQ95yL3bygza_y3ep6yG_dIulPTj0BV5AJQGTJrrkVw&s=QmnYKKBrQ82XA8HbHdxr53PdzOW-ewSZz3N56UZaoSk&e=>
[LinkedIn]<https://urldefense.proofpoint.com/v2/url?u=https-3A__www.linkedin.com_company-2Dbeta_3488_&d=DwMGaQ&c=znOEDNGT1crOtqImlna_pg&r=aFahRJmcW_kqFPEhKEJYOH6InoYTcYsaDFJJXjqEk4o&m=sQ95yL3bygza_y3ep6yG_dIulPTj0BV5AJQGTJrrkVw&s=i7uiluKw8lUQ1hjIA305fn9tTQVg-48SQ5x2-3qPCso&e=>
[Youtube]<https://urldefense.proofpoint.com/v2/url?u=https-3A__www.youtube.com_user_SafranMorpho_&d=DwMGaQ&c=znOEDNGT1crOtqImlna_pg&r=aFahRJmcW_kqFPEhKEJYOH6InoYTcYsaDFJJXjqEk4o&m=sQ95yL3bygza_y3ep6yG_dIulPTj0BV5AJQGTJrrkVw&s=sMYajHGrgeFA_F1VTl6qkdJpWZ-Ua0GLd87rYvk7rcI&e=>
[www.idemia.com]<https://www.idemia.com/>
De : Gaurav Mishra ***@***.***>
Envoyé : vendredi 10 mars 2023 16:47
À : fossology/fossology ***@***.***>
Cc : NOBLANC Yanick ***@***.***>; Mention ***@***.***>
Objet : Re: [fossology/fossology] REST API: Incoherent /search result (#1481)
Ce message provient d'un expéditeur externe - faites attention aux liens et pièces jointes qu'il contient.
…________________________________
And now all REST api search requests are failing returning something like this
<script>(function (c) {if (c && c.groupCollapsed) {
c.log("%c% ...
...
l");
}})(console);</script>
@YanickNoblanc<https://urldefense.com/v3/__https:/github.com/YanickNoblanc__;!!FZtbJVnXfw!w6xcAEOTQaDA6F2AXHFUcDyUA519wsCJPLNvLnu_ODmHv_3G_8sdOZAK7498WyoHT-V0hes4iqBuap7FKR3ioZ_1GeFo$> that's not supposed to happen. Can you please share your error.log file?
It is generally located in /var/log/apache2/error.log
—
Reply to this email directly, view it on GitHub<https://urldefense.com/v3/__https:/github.com/fossology/fossology/issues/1481*issuecomment-1463997609__;Iw!!FZtbJVnXfw!w6xcAEOTQaDA6F2AXHFUcDyUA519wsCJPLNvLnu_ODmHv_3G_8sdOZAK7498WyoHT-V0hes4iqBuap7FKR3iobeiQRN8$>, or unsubscribe<https://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/AJ7VP53O2XMSU2M5DEH74CDW3NEHDANCNFSM4IYWI6KA__;!!FZtbJVnXfw!w6xcAEOTQaDA6F2AXHFUcDyUA519wsCJPLNvLnu_ODmHv_3G_8sdOZAK7498WyoHT-V0hes4iqBuap7FKR3ioSI4LzLN$>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Thank you for the logs @YanickNoblanc . I will reopn the issue and provide a fix for it. |
Description
There seems to be a problem with the REST API
/search
feature.When uploading several times the same files, searching the file returns the correct number of entries, but all information is identical (match the first upload)
Tested via the REST API.
How to reproduce
{ "code": 201, "message": 31, "type": "INFO" }
{ "code": 201, "message": 32, "type": "INFO" }
curl -k -s -S -X GET https://<server>/api/v1/search -H "Authorization:Bearer eyJ..." -H filename:reuse_3.zip | jq .
Versions
Recent version fro Master
The text was updated successfully, but these errors were encountered: