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

Errors editing after import #4422

Open
rcruz-pntlb opened this issue Oct 17, 2024 · 1 comment
Open

Errors editing after import #4422

rcruz-pntlb opened this issue Oct 17, 2024 · 1 comment

Comments

@rcruz-pntlb
Copy link
Contributor

rcruz-pntlb commented Oct 17, 2024

Hi! all,

I detected some malfunction when importing from CSV file. Thanks in advance for your help/advice/hints ;-)... so here we go,

Describing general config:

  • Ubuntu 20.04.6 LTS
  • PHP version: 8.1.29
  • Current Teampass version loaded 3.1.2.52
  • Settings: ["Import from KeePass or CSV files enabled":yes,"Managers may edit or delete any items they can view":yes, "New sub-folders inherit permissions from parent folder":no, "Allow restricting items to users and roles": yes, "Can create a folder at root level": yes,"Folders may have duplicate names":yes]
  • Existing Role "IT" assigned to Administrator users includes rights for adding/editing/deleting on any folder.
  • Web client: Chrome versión 129.0.6668.101 (Build oficial) (64 bits) / Windows 11 23H2

Steps to reproduce

  1. From a user with IT role, I create a new directory, specifying ["Test Label","Root", "Weak","",""] and save.
  2. From import option I choose a testing file, content as follows:
    label,login,password,url,comments
    "Logan","MyLogan","YoupiCheap","http://www.logan.fr",""
    "Logan2","MyLogan2","YoupiCheap2","http://www.logan2.fr",""
    "Logan3","MyLogan3","YoupiCheap3","http://www.logan3.fr",""
    "Logan4","MyLogan4","YoupiCheap4","http://www.logan4.fr",""
    "Logan5","MyLogan5","YoupiCheap5","http://www.logan5.fr",""
    "Logan6","MyLogan6","YoupiCheap6","http://www.logan6.fr",""
  3. And additional parameters ["Any user could edit all imported items":checked, "Any user part of your Groups could edit all imported items":checked], target folder = "Test Label", All Items Selected ... and clicking on perform ...
  4. After import csv file, the entries are apparently in their place, with right data on it. Alright!... but when I try to edit any item and save it, a red tooltip appears on chrome showing following message: "No changes was performed". And still more, from this point, if I try to manually add new items to the same folder, the same error persists when I try to save it...

[by making use of Chrome Developer Tools]: I think, but I'm not sure about, that the Update Action (when I edit some item) is not sent to server when I click on Save button. It seems that javascript flow breaks off, registering following error at Console level (IMPORTANT! not when "edit" button is clicked, but when previously entering to item for reading data):

XHR finished loading: POST "". jquery.min.js?v=3.1.2:2 XHR finished loading: POST "https://teampass.local/sources/items.queries.php".send @ jquery.min.js?v=3.1.2:2
ajax @ jquery.min.js?v=3.1.2:2
...
index.php?page=items:8997 Uncaught TypeError: Cannot read properties of undefined (reading 'title')
at String. (index.php?page=items:8997:76)
at Function.each (jquery.min.js?v=3.1.2:2:3003)
at Object.success (index.php?page=items:8994:19)
at c (jquery.min.js?v=3.1.2:2:28327)
at Object.fireWith [as resolveWith] (jquery.min.js?v=3.1.2:2:29072)
at l (jquery.min.js?v=3.1.2:2:79901)
at XMLHttpRequest. (jquery.min.js?v=3.1.2:2:82355)
(anonymous) @ index.php?page=items:8997
each @ jquery.min.js?v=3.1.2:2
(anonymous) @ index.php?page=items:8994
c @ jquery.min.js?v=3.1.2:2
fireWith @ jquery.min.js?v=3.1.2:2
l @ jquery.min.js?v=3.1.2:2
(anonymous) @ jquery.min.js?v=3.1.2:2
load
send @ jquery.min.js?v=3.1.2:2
ajax @ jquery.min.js?v=3.1.2:2
S. @ jquery.min.js?v=3.1.2:2
showDetailsStep2 @ index.php?page=items:8899
(anonymous) @ index.php?page=items:8821
c @ jquery.min.js?v=3.1.2:2
fireWith @ jquery.min.js?v=3.1.2:2
l @ jquery.min.js?v=3.1.2:2
(anonymous) @ jquery.min.js?v=3.1.2:2
load
send @ jquery.min.js?v=3.1.2:2
ajax @ jquery.min.js?v=3.1.2:2
S. @ jquery.min.js?v=3.1.2:2
(anonymous) @ index.php?page=items:8250
e @ jquery.min.js?v=3.1.2:2
t @ jquery.min.js?v=3.1.2:2
setTimeout
(anonymous) @ jquery.min.js?v=3.1.2:2
c @ jquery.min.js?v=3.1.2:2
fireWith @ jquery.min.js?v=3.1.2:2
fire @ jquery.min.js?v=3.1.2:2
c @ jquery.min.js?v=3.1.2:2
fireWith @ jquery.min.js?v=3.1.2:2
e @ jquery.min.js?v=3.1.2:2
t @ jquery.min.js?v=3.1.2:2
setTimeout
(anonymous) @ jquery.min.js?v=3.1.2:2
c @ jquery.min.js?v=3.1.2:2
fireWith @ jquery.min.js?v=3.1.2:2
fire @ jquery.min.js?v=3.1.2:2
c @ jquery.min.js?v=3.1.2:2
fireWith @ jquery.min.js?v=3.1.2:2
s. @ jquery.min.js?v=3.1.2:2
Promise.then
I @ jquery.min.js?v=3.1.2:2
when @ jquery.min.js?v=3.1.2:2
Details @ index.php?page=items:8136
(anonymous) @ index.php?page=items:5982
dispatch @ jquery.min.js?v=3.1.2:2
v.handle @ jquery.min.js?v=3.1.2:2 Understand this error

on access.log

(when csv imported and when edited some item)


<some-client-ip> - - [17/Oct/2024:13:15:58 +0200] "POST /sources/main.queries.php HTTP/1.1" 200 1408 "https://<myteampassdomainname>/index.php?page=import" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
<some-client-ip> - - [17/Oct/2024:13:15:58 +0200] "POST /sources/main.queries.php HTTP/1.1" 200 488 "https://<myteampassdomainname>/index.php?page=import" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
<some-client-ip> - - [17/Oct/2024:13:15:58 +0200] "POST /sources/main.queries.php HTTP/1.1" 200 1126 "https://<myteampassdomainname>/index.php?page=import" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
<some-client-ip> - - [17/Oct/2024:13:16:05 +0200] "POST /sources/main.queries.php HTTP/1.1" 200 2526 "https://<myteampassdomainname>/index.php?page=import" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
<some-client-ip> - - [17/Oct/2024:13:16:05 +0200] "POST /sources/upload.files.php HTTP/1.1" 200 1074 "https://<myteampassdomainname>/index.php?page=import" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
<some-client-ip> - - [17/Oct/2024:13:16:05 +0200] "POST /sources/import.queries.php HTTP/1.1" 200 1785 "https://<myteampassdomainname>/index.php?page=import" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
<some-client-ip> - - [17/Oct/2024:13:16:05 +0200] "GET /plugins/icheck/skins/flat/blue.png HTTP/1.1" 200 1825 "https://<myteampassdomainname>/plugins/icheck/skins/flat/_all.css" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
<some-client-ip> - - [17/Oct/2024:13:16:24 +0200] "POST /sources/import.queries.php HTTP/1.1" 200 1498 "https://<myteampassdomainname>/index.php?page=import" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
<some-client-ip> - - [17/Oct/2024:13:16:55 +0200] "GET /index.php?page=items HTTP/1.1" 200 73595 "https://<myteampassdomainname>/index.php?page=import" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
<some-client-ip> - - [17/Oct/2024:13:16:56 +0200] "POST /sources/main.queries.php HTTP/1.1" 200 1399 "https://<myteampassdomainname>/index.php?page=items" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
<some-client-ip> - - [17/Oct/2024:13:16:56 +0200] "GET /sources/tree.php HTTP/1.1" 200 2671 "https://<myteampassdomainname>/index.php?page=items" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
<some-client-ip> - - [17/Oct/2024:13:16:56 +0200] "POST /sources/main.queries.php HTTP/1.1" 200 488 "https://<myteampassdomainname>/index.php?page=items" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
<some-client-ip> - - [17/Oct/2024:13:16:56 +0200] "POST /sources/main.queries.php HTTP/1.1" 200 1129 "https://<myteampassdomainname>/index.php?page=items" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
<some-client-ip> - - [17/Oct/2024:13:16:56 +0200] "POST /sources/items.queries.php HTTP/1.1" 200 4650 "https://<myteampassdomainname>/index.php?page=items" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
<some-client-ip> - - [17/Oct/2024:13:16:56 +0200] "POST /sources/items.queries.php HTTP/1.1" 200 1013 "https://<myteampassdomainname>/index.php?page=items" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
<some-client-ip> - - [17/Oct/2024:13:16:57 +0200] "POST /sources/items.queries.php HTTP/1.1" 200 10083 "https://<myteampassdomainname>/index.php?page=items" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
<some-client-ip> - - [17/Oct/2024:13:16:57 +0200] "POST /sources/items.queries.php HTTP/1.1" 200 5424 "https://<myteampassdomainname>/index.php?page=items" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
<some-client-ip> - - [17/Oct/2024:13:16:57 +0200] "POST /sources/items.queries.php HTTP/1.1" 200 4650 "https://<myteampassdomainname>/index.php?page=items" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
<some-client-ip> - - [17/Oct/2024:13:16:58 +0200] "POST /sources/items.queries.php HTTP/1.1" 200 1015 "https://<myteampassdomainname>/index.php?page=items" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
<some-client-ip> - - [17/Oct/2024:13:17:25 +0200] "POST /sources/items.queries.php HTTP/1.1" 200 1562 "https://<myteampassdomainname>/index.php?page=items" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
<some-client-ip> - - [17/Oct/2024:13:17:25 +0200] "POST /sources/items.queries.php HTTP/1.1" 200 1876 "https://<myteampassdomainname>/index.php?page=items" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
<some-client-ip> - - [17/Oct/2024:13:17:25 +0200] "POST /sources/items.queries.php HTTP/1.1" 200 1179 "https://<myteampassdomainname>/index.php?page=items" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
<some-client-ip> - - [17/Oct/2024:13:17:36 +0200] "POST /sources/items.queries.php HTTP/1.1" 200 3261 "https://<myteampassdomainname>/index.php?page=items" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
<some-client-ip> - - [17/Oct/2024:13:17:36 +0200] "POST /sources/items.queries.php HTTP/1.1" 200 1803 "https://<myteampassdomainname>/index.php?page=items" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
<some-client-ip> - - [17/Oct/2024:13:17:40 +0200] "GET /plugins/icheck/skins/flat/blue.png HTTP/1.1" 200 1825 "https://<myteampassdomainname>/plugins/icheck/skins/flat/_all.css" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
<some-client-ip> - - [17/Oct/2024:13:18:07 +0200] "POST /sources/items.queries.php HTTP/1.1" 200 798 "https://<myteampassdomainname>/index.php?page=items" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"

on errors.log

(when csv imported and when edited some item)

[Thu Oct 17 13:17:25.135390 2024] [php:notice] [pid 3146802] [client <some-client-ip>:58177] TEAMPASS - Folder: 65 - User: 10000003 - access: W - edit: 1 - delete: , referer: https://myteampassdomainname/index.php?page=items
[Thu Oct 17 13:17:36.087129 2024] [php:notice] [pid 3155131] [client <some-client-ip>:58180] TEAMPASS - Folder: 65 - User: 10000003 - access: W - edit: 1 - delete: , referer: https://myteampassdomainname/index.php?page=items

Looking Forward to hearing from you

Additional info (added 10/18/24)

I've noticed, when clicked on any imported item, that the "History section" header appears with grey color showing up the "loading" icon. And it remains like this forever (capture attached)

teampass-imported-item-example

@rcruz-pntlb
Copy link
Contributor Author

rcruz-pntlb commented Oct 25, 2024

Hi all!... finally I found the error related with this thread.

After days debbuging backend and frontend code flows, I arrived to some solution. If someone (referring to active developers) happen to read this thread, hope to review my proposal and do things in an appropiate way according to the development guidelines of Teampass project.

The problem comes from pages/items.js.php, specifically this jquery code related with Restrictions and Roles:

$.each(store.get('teampassItem').id_restricted_to_roles, function(i, value) { html_restrictions += '<span class="badge badge-info mr-2 mb-1"><i class="fa-solid fa-group fa-sm mr-1"></i>' + data.roles_list.find(x => x.id === parseInt(value)).title + '</span>'; });

The case is, when you import from csv, I don't know the real reason but the attribute "title" is not available, so it's throwing an Uncaught Exception when a posteriori you try to edit any imported item. Maybe due to my specific teampass config, and relating to any imported item's editing, into this code block the parameter "value" is always different from 0 or null, and with this scenario data.roles_list.find(x => x.id === parseInt(value)).title throws the commented error because it doesn't find "title" attribute.

At this time, I replaced this code by this one, in order to ensure (at least) that the execution flow is not interrupted :

$.each(store.get('teampassItem').id_restricted_to_roles, function(i, value) { const role = data.roles_list.find(x => x.id === parseInt(value)); html_restrictions += (role ? '<span class="badge badge-info mr-2 mb-1"><i class="fa-solid fa-group fa-sm mr-1"></i>' + role.title + '</span>' : ''); });

Best Regards,

rcruz-pntlb added a commit to rcruz-pntlb/TeamPass that referenced this issue Oct 29, 2024
…-imported items

This commit addresses a bug where items, after being imported via CSV, throws errors when saved. The issue was due to missing role validation in the HTML rendering process, and it specifically affects the `pages/items.js.php` script.

Changes include:
- Added a role existence check before adding HTML badge elements.
- Refactored the HTML generation loop to ensure robustness if roles are missing in `data.roles_list`.

Original issue: nilsteampassnet#4422
nilsteampassnet added a commit that referenced this issue Oct 31, 2024
…fter-csv-import

Fix issue #4422: Resolve edit errors on previously CSV-imported items
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant