Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Error: "Failed to add a file, if you see this please report a bug", when passing an undefined parameter to ipfs.add() #3788

Closed
chrispanag opened this issue Aug 5, 2021 · 2 comments · Fixed by #3818
Labels
need/triage Needs initial labeling and prioritization

Comments

@chrispanag
Copy link

chrispanag commented Aug 5, 2021

  • Version:
    0.55.4

  • Platform:
    MacOS: Darwin Christoss-MBP 20.6.0 Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:31 PDT 2021; root:xnu-7195.141.2~5/RELEASE_X86_64 x86_64
    NodeJS Version: v14.15.4

  • Subsystem:
    ipfs-core

Severity:

Medium - A non-essential functionality does not work, performance issues, etc.

Description:

  • Adding an undefined variable to my js-ipfs node by using the add method
  • It threw an error: "Failed to add a file, if you see this please report a bug"
  • I was expecting to throw a more descriptive error (eg: file is undefined)

Steps to reproduce the error:

const { cid } = await ipfs.add(undefined);
console.log(cid);

As I see by the code here, the possibility of an undefined variable passed into addAll() was not expected

const result = await last(addAll(entry, options))
// Note this should never happen as `addAll` should yield at least one item
// but to satisfy type checker we perfom this check and for good measure
// throw an error in case it does happen.
if (result == null) {
    throw Error('Failed to add a file, if you see this please report a bug')
}
@chrispanag chrispanag added the need/triage Needs initial labeling and prioritization label Aug 5, 2021
@welcome
Copy link

welcome bot commented Aug 5, 2021

Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review.
In the meantime, please double-check that you have provided all the necessary information to make this process easy! Any information that can help save additional round trips is useful! We currently aim to give initial feedback within two business days. If this does not happen, feel free to leave a comment.
Please keep an eye on how this issue will be labeled, as labels give an overview of priorities, assignments and additional actions requested by the maintainers:

  • "Priority" labels will show how urgent this is for the team.
  • "Status" labels will show if this is ready to be worked on, blocked, or in progress.
  • "Need" labels will indicate if additional input or analysis is required.

Finally, remember to use https://discuss.ipfs.io if you just need general support.

@chrispanag chrispanag changed the title Error: Failed to add a file, if you see this please report a bug Error: Failed to add a file, if you see this please report a bug, when passing an undefined parameter to ipfs.add() Aug 5, 2021
@chrispanag chrispanag changed the title Error: Failed to add a file, if you see this please report a bug, when passing an undefined parameter to ipfs.add() Error: "Failed to add a file, if you see this please report a bug", when passing an undefined parameter to ipfs.add() Aug 5, 2021
achingbrain added a commit that referenced this issue Aug 17, 2021
Throws an error with a more descriptive error message.

The error messages over http are not descriptive due to node-fetch/node-fetch#753

Fixes #3788
achingbrain added a commit that referenced this issue Aug 17, 2021
Throws an error with a more descriptive error message.

The error messages over http are not descriptive due to node-fetch/node-fetch#753

Fixes #3788
achingbrain added a commit that referenced this issue Aug 17, 2021
Throws an error with a more descriptive error message.

The error messages over http are not descriptive due to node-fetch/node-fetch#753

Fixes #3788
@chrispanag
Copy link
Author

Thank you @achingbrain!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
need/triage Needs initial labeling and prioritization
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant