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

404 Error after upload #44

Open
alexWaterfront opened this issue Jul 7, 2022 · 59 comments
Open

404 Error after upload #44

alexWaterfront opened this issue Jul 7, 2022 · 59 comments
Assignees
Labels
bug Something isn't working

Comments

@alexWaterfront
Copy link

After i click on choose file and i select a csv document
first screen

it just shows me a 404 error see image attached:

image

@HeadStudios
Copy link

I just had this issue... so going to check this - first time I'm trying to figure out how this whole thing works... I guess I have to update the files downloaded by my composer require thingie with this new commit let me check

@jigsawsoul
Copy link

Same issue for me, it's just returning a 404

@HeadStudios
Copy link

Just wanted to pipe in - the link included here: #45 - fixed the 404 issue for me. I just copy/pasted the raw file and replaced the src/Http/Controllers/ImportController.php file from here: 8dd4796 .... so if you do that it should fix it... however that didn't solve "ALL" my problems because after I did that I could import - everything looks good on the import and it says 28 records imported successfully or whatever... but... nothing is imported!

Hopefully the creator peeks in here - because this has a lot of potential for me and I'm sure the fix to my thing is fairly straightforward - btw for anyone experiencing this issue - let me know if doing what I recommended fixed your issue and if you encounter the "second" import issue I encountered (where everything works... but it doesn't really work if that makes sense)

@alexWaterfront
Copy link
Author

Thanks for the input everyone hopefully by getting traction the author will have a look soon. I tried your solution @HeadStudios but unfortunately it didn't work for me I still get 404 error.

@HeadStudios
Copy link

@alexWaterfront that's a shame... yes please keep me updated... I am one step ahead (404 page fixed.. imports not working) - but hoping to get resolution.. let's work together and keep each other informed - I'll be checking back here.

@gcjbr
Copy link

gcjbr commented Jul 23, 2022

My PR only prevents the 404, but the Resource causing it can't be configured when imported.

The error goes all the way to NovaRequest's rulesForCreation method, but I can't pinpoint what's the difference between the Resources that are being imported successfully and those which are not

@HeadStudios
Copy link

Hm good point, I've only tried one Resource for import - I could technically try other Resources to see if the issue is with my resources.. like I could try and import some Users as that is like the default mode. I appreciate your PR though because copy/pasting that did help me get to the next step.. I don't know why this Debugbar or whatever it is won't show me the SQL query that is attempted to be performed on insert.. I'm new to Laravel and not the best at debugging - but you've given me the idea to test with other resources to try to pinpoint the problem down - and thank for rulesForCreation method to look at. Chrs.

@archambaultalex
Copy link

Got the same problem. I am getting a 404 error when uploading the csv file.
For me, the error was caused by resources that had a belongsTo field.
In ImportController@extractValidationRule the function $resource::rulesForCreation is called which in turn calls the function getCreationRules at /nova/src/PerformsValidation@rulesForCreation on each field.
For a reason that I do not understand, if it's called on a belongsTo field, it returns a 404 error.

@gcjbr
Copy link

gcjbr commented Jul 25, 2022

Got the same problem. I am getting a 404 error when uploading the csv file. For me, the error was caused by resources that had a belongsTo field. In ImportController@extractValidationRule the function $resource::rulesForCreation is called which in turn calls the function getCreationRules at /nova/src/PerformsValidation@rulesForCreation on each field. For a reason that I do not understand, if it's called on a belongsTo field, it returns a 404 error.

Same

@HeadStudios
Copy link

Hmmmm.... interesting... because the resource I'm importing into - there's a chance that has a BelongsTo field to... or more so a BelongsTo function or something.. I will test without them and see what happens... but I know the table doesn't have any remote fields... what's interseting is that there's no error being made... and I am sooo bad at troubleshooting - like all this stuff you guys are saying - I have no idea how to check that out. On my end I just get a success message - actually I should post what happens on my side here soon.. I feel like I'm so close to a solution though (I even have a success page saying "38 contacts of 38 contacts have been imported" and stuff.

@gcjbr
Copy link

gcjbr commented Jul 25, 2022 via email

@HeadStudios
Copy link

Yes I'll try and import to users or something with no relationships... the thing is the Resource I'm importing doesn't have any related id fields... like for example Contacts doesn't have any foreign id keys or anything fancy at the database level - https://share.getcloudapp.com/wbuXqE7e - ... so I'm just doing name, mobile, email. The thing is on the Model level I do have the following:

ublic function campaign_contacts() {
return $this->belongsToMany(CampaignContact::class);
}

So it does belongsTo... but it doesn't have to.. I don't know if I'm making sense - I'm wondering if your mapping short circuits if on the model it has belongsTo... because I can create contacts without associating them (in fact I can't associate them on the creation in nova level) to campaign contacts or anything.. not sure if I described it correctly.. I can try removing that belongs to or campaign_contacts() function too and see if it works - but thanks for clarifying that it short circuits - just trying to figure out this mystery - any input much appreciated!

@petervandijck
Copy link

Having the same issue, anyone working on this (aside from the above comments)?

@HeadStudios
Copy link

I might put this over to Fiverr and see if someone is willing to work and fix it... if I find a solution I'll come back here and share - you guys better throw me some pennies if I do though lol.

@morcov
Copy link
Contributor

morcov commented Aug 12, 2022

Problem in NovaRequest in method resource by call in BelongsTo::associatableQueryCallable

public function resource()
    {
        return tap(once(function () {
            return Nova::resourceForKey($this->route('resource'));
        }), function ($resource) {
            abort_if(is_null($resource), 404);
        });
    }

Request can't get value $this->route('resource') because there is none. For resolve can use custom request with replacement this method. Example

    public function resource()
    {
          return $this->importResource;
    }

I can't create a pull request right now, maybe later

@HeadStudios
Copy link

Problem in NovaRequest in method resource by call in BelongsTo::associatableQueryCallable

public function resource()
    {
        return tap(once(function () {
            return Nova::resourceForKey($this->route('resource'));
        }), function ($resource) {
            abort_if(is_null($resource), 404);
        });
    }

Request can't get value $this->route('resource') because there is none. For resolve can use custom request with replacement this method. Example

    public function resource()
    {
          return $this->importResource;
    }

I can't create a pull request right now, maybe later

Wait.. so I just... find and replace that code and (theoretically) it should work? I will try tomorrow!

@pedami
Copy link

pedami commented Aug 13, 2022

Hola tengo el mismo problema.
Esperamos que mañana lo resuelva @HeadStudios

Gracias.

@HeadStudios
Copy link

Hola tengo el mismo problema. Esperamos que mañana lo resuelva @HeadStudios

Gracias.

Hello Spanish person. Had to translate what you said but yes excited about getting this fixed too.

@HeadStudios
Copy link

Problem in NovaRequest in method resource by call in BelongsTo::associatableQueryCallable

public function resource()
    {
        return tap(once(function () {
            return Nova::resourceForKey($this->route('resource'));
        }), function ($resource) {
            abort_if(is_null($resource), 404);
        });
    }

Request can't get value $this->route('resource') because there is none. For resolve can use custom request with replacement this method. Example

    public function resource()
    {
          return $this->importResource;
    }

I can't create a pull request right now, maybe later

This crashed for me when I replaced this function in Nova... or am I meant to make another function? I'm trying to comment the abort part out to see if this puts the CSV import through.. I have no idea what I'm doing lol.

@HeadStudios
Copy link

Problem in NovaRequest in method resource by call in BelongsTo::associatableQueryCallable

public function resource()
    {
        return tap(once(function () {
            return Nova::resourceForKey($this->route('resource'));
        }), function ($resource) {
            abort_if(is_null($resource), 404);
        });
    }

Request can't get value $this->route('resource') because there is none. For resolve can use custom request with replacement this method. Example

    public function resource()
    {
          return $this->importResource;
    }

I can't create a pull request right now, maybe later

This didn't help unfortunately :( any other input much appreciated - or if I'm doing something wrong. Chrs!

@morcov
Copy link
Contributor

morcov commented Aug 13, 2022

My PR #47

@HeadStudios
Copy link

My PR #47

Niiice! Just had a look - can't wait to try over on my side. Looking forward to it!

@pedami
Copy link

pedami commented Aug 13, 2022

My PR #47

Niiice! Just had a look - can't wait to try over on my side. Looking forward to it!

Muchas gracias, esto funciona ;-)

@HeadStudios
Copy link

My PR #47

Sorry :( - just tried and it has not fixed my issue - I do import and just like before it says success records imported but when I go to look nothing has been imported :(

@pedami
Copy link

pedami commented Aug 13, 2022

Hello, it worked for me the second time, because I wasn't passing all the mandatory fields, try to pass all the fields that are mandatory and it will work for you.

@HeadStudios
Copy link

Hello, it worked for me the second time, because I wasn't passing all the mandatory fields, try to pass all the fields that are mandatory and it will work for you.

Hey, I have a contacts with only 3 fields (name, email, phone) - I pass all fields and it says success but no records imported :(

@HeadStudios
Copy link

It says Imported but... not really - https://share.getcloudapp.com/kpuW9qp1 - btw that #47 pull request did help! But... there's just no import happening despite it saying that is so.. yeh.

@Erkenz
Copy link

Erkenz commented Jan 26, 2023

@rafaelsmith no not for me but i could help you with the import you can contact me in discord if you want erkenzjordi#5675

@simonhamp
Copy link
Owner

Hey folks. Please if you can, share the relevant CSV import code, a sample of the CSV data you're trying to import and any relevant DB migrations and I will be more than happy to investigate and fix.

It will be great if you could also let me know what version(s) of Nova and this plugin you've got installed.

@HeadStudios
Copy link

Has anyone made it work?

Yeh I had to hack core but I got it working to what I need - I basically did a conditional and I even modified drop downs and everything - I'm on Discord if you want to jump in - I'm in the Laravel group and can share what I did. But it seems like hte guy who made is around now so perhaps he can assist.

@rafaelsmith
Copy link

Hey folks. Please if you can, share the relevant CSV import code, a sample of the CSV data you're trying to import and any relevant DB migrations and I will be more than happy to investigate and fix.

It will be great if you could also let me know what version(s) of Nova and this plugin you've got installed.

The file very simple you can see here: https://gist.github.com/rafaelsmith/ed22e90be4c74e7945d8be3390aece63
The Nova version is v4.21.0

Thanks in advance! :)

@Stefan-Dressler
Copy link

Hi @simonhamp

Firstly, thanks for providing this package. Very usefully. I have tested it yesterday and ran into the issue described here. I tried all versions and 0.4.0 is the last working version for Nova 4. We are also running on Nova 4.21.0.

Maybe this is helpful for you.

@torrancemiller
Copy link

It would be really great if this package worked! Has anyone made a working fork of this?

@HeadStudios
Copy link

It would be really great if this package worked! Has anyone made a working fork of this?

I did get this working after modifying some stuff though I don't remember exactly what I did lol, I don't think I made a fork either. But I can confirm with some slight changes it does work.

@chrillep
Copy link
Contributor

chrillep commented Feb 25, 2023

filter out supported fields from $fieldsCollection before getting fields?

        $fieldsCollection = $fieldsCollection->filter(fn (Field $field) => !($field instanceof BelongsTo));

excludeAttributesFromImport should do this?

@simonhamp simonhamp added the bug Something isn't working label Mar 5, 2023
@rafaelsmith
Copy link

Hey folks. Please if you can, share the relevant CSV import code, a sample of the CSV data you're trying to import and any relevant DB migrations and I will be more than happy to investigate and fix.

It will be great if you could also let me know what version(s) of Nova and this plugin you've got installed.

Hey mate any update for us? :)

@simonhamp
Copy link
Owner

@rafaelsmith your file isn't a CSV... it's using semicolons. That's why it won't work... I've not configured it to support all of the weird and wonderful ways CSVs might be written...

Can you change your data so that it does use commas?

@rafaelsmith
Copy link

rafaelsmith commented Mar 8, 2023

@rafaelsmith your file isn't a CSV... it's using semicolons. That's why it won't work... I've not configured it to support all of the weird and wonderful ways CSVs might be written...

Can you change your data so that it does use commas?

Thank you for your reply, unfortunately also after changing it to commas I get the same 404 error.
Also the url after upload the file is nova/csv-import/configure/1828f0efd066b0f17ef30c9d446355ea.txt

@simonhamp
Copy link
Owner

@rafaelsmith why is the extension now .txt? Please make sure it's a .csv file with CSV data inside. The code that handles the files won't know how to treat it otherwise

@rafaelsmith
Copy link

@rafaelsmith why is the extension now .txt? Please make sure it's a .csv file with CSV data inside. The code that handles the files won't know how to treat it otherwise

I export CSV file directly from Google Sheets.

@hamza-darvis
Copy link

hamza-darvis commented Mar 15, 2023

Not working for
nova/csv-import/configure/f8b142ec31a75df933caeed75c2f0495.csv
Sample csv from https://sample-videos.com/download-sample-csv.php#google_vignette

@simonhamp
Copy link
Owner

@hamza-darvis which file did you pick to test (how many rows)? And which version of CSV import are you running?

@hamza-darvis
Copy link

hamza-darvis commented Mar 16, 2023

@simonhamp 5000 rows and I'm using CSV import version 0.6.4 with nova 4

@kevin-dapps
Copy link
Contributor

I've having the same issue as @hamza-darvis on CSV import version 0.6.4 with Nova 4.0

@kevin-dapps
Copy link
Contributor

kevin-dapps commented Apr 12, 2023

Downgrading to v0.4.0 of this package as @Stefan-Dressler advised, resolved the issue. However I would like to use the latest version if possible

@simonhamp
Copy link
Owner

@simonhamp 5000 rows and I'm using CSV import version 0.6.4 with nova 4

@hamza-darvis Thanks. I will try to look at this soon

@inkly
Copy link

inkly commented May 2, 2023

Hello here,

I have found this 404 come when I have BelongTo relation in one of my nova ressource

@simonhamp
Copy link
Owner

@inkly this package currently can't handle relationships for you. There's an issue open for this already (#5)

This thread seems to mostly be related to a slightly different issue.

@philsturgeon
Copy link

#47 fixes this problem perfectly.

Give it a go.

{
    "require": {
        "simonhamp/laravel-nova-csv-import": "dev-fixing-belong-to-relation",
    },

    "repositories": [
        {
            "type": "vcs",
            "url":  "[email protected]:morcov/laravel-nova-csv-import.git"
        }

@simonhamp
Copy link
Owner

#47 has been merged and released in v0.7.0

@yunior22
Copy link

Hey guys, I had the same issue with getting a 404 error. Using the Nova Tag field or a third-party multi-select field for relationships will cause the error. A workaround I’m using is creating a clone of the resource. I called it Import[Resource] to differentiate the two. Remove the relationship fields from the clone.

Set the public static $canImportResource = true; on the clone resource and false on the actual resource.

This may only be useful for some.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests