Issues importing from CSV in 4.0.6
Hey, I have a few issues importing from a CSV:
1. Cannot import via command-line due to error
Expected Behavior
Run php artisan snipeit:import /import.csv and have files successfully imported.
Actual Behavior
snipeit@camp:/opt/snipe-it$ php artisan snipeit:import /import.csv
[Symfony\Component\Console\Exception\InvalidArgumentException]
The "testrun" option does not exist.
2. Cannot import via web-interface, hangs at "Processing"
Expected Behavior
Go to Import page, select import CSV, set Assets import type and map Model Name, Asset Tag, and Status fields, then click "Import" and have the assets imported.
Actual Behavior
Go to Import page, select import CSV, set Assets import type and map fields, then click "Import". There is a green bar that hangs at "Processing".
Please confirm you have done the following before posting your bug report:
- [x] I have enabled debug mode
- [x] I have read checked the Common Issues page
Please provide answers to these questions before posting your bug report:
-
Version of Snipe-IT you're running 4.0.6 (fresh install, pulled from git today around 4:10 PM PST) because I thought maybe re-installing would fix the issue that I can't see the debug bar at the bottom of the screen. The database is from a fresh 4.0 installation, upgraded through 4.0.6
-
What OS and web server you're running Snipe-IT on Ubuntu Server 16.04 and Apache 2.4.18
-
What method you used to install Snipe-IT (install.sh, manual installation, docker, etc) git clone / manual installation
-
WITH DEBUG TURNED ON, if you're getting an error in your browser, include that error For some reason, I have
APP_DEBUG=truein my.envfile, but I am not seeing the normal debug bar at the bottom of the page. I AM seeing the warning at the top that says "This application is running in production mode with debugging enabled." I thought maybe something was wrong with my installation, so I just tried a fresh install again, and am still getting the same thing.
However, when I first started to diagnose the problem, I DID have the bar, and I checked the errors (I think that's what it's called) tab and didn't see anything.
-
What specific Snipe-IT page you're on, and what specific element you're interacting with to trigger the error
/importand clicking theImportbutton after mapping assets. -
If a stacktrace is provided in the error, include that too. Can't see debug bar. If there are logs anywhere else, I'm happy to provide them.
-
Any errors that appear in your browser's error console. I get this error as soon as I click "Select Import File" and upload the CSV (so before mapping/processing) I get this error when I click the "Import" button after mapping CSV fields.
-
Confirm whether the error is reproduceable on the demo. Importing is disabled on the demo.
-
Include any additional information you can find in
app/storage/logsand your webserver's logs. No errors inlaravel.log. The only few log lines are regarding my LDAP login. -
Include what you've done so far in the installation, and if you got any error messages along the way. No errors, I followed the steps for a full installation, keeping in-place my database (which was from a clean 4.0 installation and then upgraded up to 4.06) and re-copying my
.envfile. -
Indicate whether or not you've manually edited any data directly in the database I have not modified any data directly in the database.
@dmeltzer maybe you can take a look at this at the same time as you're working through some of the other importer issues?
It looks like this is two separate issues. The CLI importer part should be fixed with #4079. Are there any errors in your javascript console when running the web importer?
@dmeltzer Yes, I linked to some gists with them in the issue, but I'll paste them here:
I get this error as soon as I click "Select Import File" and upload the CSV (so before mapping/processing):
all.js:20 Uncaught (in promise) TypeError: Cannot read property 'forEach' of undefined
at r.<anonymous> (all.js:20)
at <anonymous>
I get this error when I click the "Import" button after mapping CSV fields:
Uncaught TypeError: Cannot read property 'replace' of undefined
at r.processUrl (all.js:19)
at Vo.get (all.js:17)
at Vo.evaluate (all.js:17)
at r.processUrl (all.js:15)
at r.postSave (all.js:20)
at i (all.js:15)
at HTMLButtonElement.e (all.js:15)
Ah, I think this is fixed on the develop branch (or, alternatively, if you refresh the page). If not, can you please let us know?
I pulled master down just now and it seems fixed! Thanks!
I have a few pieces of feedback on the process. I don't know if you want to open issues for these or if they are really problems.
-
I created my CSV file in Excel, so there were some rows with no data in them at the end that were invisible in Excel. I got this error in Snipe-IT:
Asset "": The model id field is required.The asset tag field is required.I opened the CSV in Notepad and sure enough, there were several rows of of
,,,,,,,. It might be best to just silently ignore empty rows if possible? -
The "Processing" bar changed to say "Error" because of the above issue, but still stayed green even though there was an error. Red might be a better color on error.
-
Even though the result was "Error", it still imported the records it could. That was not immediately obvious until I went back to view the assets.
- There are also two log entries added for each asset imported. Not sure if this is intended. One is "create new" and the other is "item created" with notes "Imported using csv importer".
@dmeltzer
Actually, this might not be fixed completey. Going back to the Import page now just shows me a blank page with the "Import" header. I'm getting some Vue errors in the JS console. Posted on gist here.
ah. Does it work if your APP_ENV is set to level in the .env file? (Don't need to keep it like this.. just curious if it fixes..) @snipe looks like we should keep the production build of js in git I guess then.
So, APP_ENV=level? No, it's still broken then. Or was that a typo/autocorrect?
APP_ENV=debug. Or try pulling from git again, we tried a different option.
APP_ENV=debug did not fix the issue. I still received the JS errors.
master had no changes, I still get the errors.
I tried switching to develop. I don't have console errors there, but still a blank page.
APP_ENV=debug isn't a valid environment really. It's typically develop or production.
Try setting APP_DEBUG=true and/or DISABLE_CSP=true. Remember to clear your config cache as well (php artisan config:clear)
(We're trying to figure out if adding the CSP security stuff unintentionally broke some stuff.)
Alright, so:
- master branch,
APP_ENV=production,APP_DEBUG=true,DISABLE_CSP=true- the page loads fine, but I get these JS errors (see gist), no debug bar exceptions - master branch,
APP_ENV=production,APP_DEBUG=true,DISABLE_CSPnot in.env- same behavior as 1 - master branch,
APP_ENV=develop,APP_DEBUG=true,DISABLE_CSPnot in.env- same behavior as 1 - master branch,
APP_ENV=develop,APP_DEBUG=true,DISABLE_CSP=true- same behavior as 1
It seems that setting APP_DEBUG=false is when it breaks, because:
- master branch,
APP_ENV=production,APP_DEBUG=false,DISABLE_CSPnot in.env- no content on page, getting the console errors from before when I reported that the page was blank - master branch,
APP_ENV=production,APP_DEBUG=false,DISABLE_CSP=true- same behavior as 1 (page loads, console errors)
Any other permutations I should test?
Hm. So it looks like the CSP isn’t the issue. Which is good, but now we’re more confused than before. We’ll try to get this sorted this weekend. I know @dmeltzer is working a lot tomorrow, but I may try to wrangle @uberbrady into this as well.
(We really appreciate your patience with these test cases, btw. It’s a really big help.)
Actually, I’m not sure CSP isn’t the issue, but adding DISABLE_CSP=true should disable it completely at the middleware level, so not 100% sure what’s happening. We have some good leads tho, and will try to get it sorted this weekend.
Try pulling the latest from develop and let me know if that works?
Even after pulling from the latest 4.0.8 build 1.0.2, the import issue persists. Kindly note that Snipe-IT is running in a subdirectory.

Javascript Console Issues:

@snipe
This appears to be fixed in master now (v4.0.8 build 102). I just pulled about 10 minutes ago. This is without DISABLE_CSP=true in .env and with APP_ENV=production and APP_DEBUG=false
I can't speak for @raakhtar but I suspect that he/she is experiencing a web server configuration error based on the console.
So I think I am all set with this issue, minus the original feedback in comments 5 and 6 above that you are free to take as you wish.
Thanks very much for your help fixing this!