Import source invalid
A refusal to import mocks from a HAR file, a Postman collection or curl commands, because the source cannot be read, or because the plan it makes has a problem.
| Field | Value |
|---|---|
type |
https://mockhub.dev/problems/import-invalid |
| Status | 422 |
What it means
Section titled “What it means”Either the source is broken where the import reads it, such as JSON that does not parse or a curl paste whose output cannot be told apart from the next command, or the entries ticked for an apply make a plan with an error. Nothing was created. A source that is fine but of a kind the import does not read is Import source unsupported instead.
A single entry the import cannot use, such as a request with a binary body, is not this refusal: the preview lists it as one that cannot be imported, and imports the others.
Status
Section titled “Status”Always 422.
Where it comes from
Section titled “Where it comes from”From previewing or applying an import, when the source cannot be read:
| When | First problem in issues |
|---|---|
| The source is empty | The source is empty |
| The source is not UTF-8 | The source is not UTF-8 text |
| The JSON does not parse, has a key twice or nests too deeply | What is wrong, such as Duplicate key "entries" |
| The format was chosen and the source is not one | A HAR has a "log" object with an "entries" array, or the same for a Postman collection or curl |
A line of a curl paste with a $ prompt runs something other than curl |
Only curl commands can be imported; this line runs something else |
Output that does not show where it ends is followed by a curl line |
The output under the command on line <n> does not show where it ends, so this curl line could be part of it. Paste commands with their -i output, or export a HAR |
| Reading the source took more than 10 seconds | Reading and planning this source took longer than 10 seconds; import fewer entries at a time |
The detail is This source cannot be imported: followed by the problem and where it is: (line <n>, column <n>). in the text, or (at <JSON Pointer>). in the content.
From applying an import, when the plan has an error:
| When | code |
|---|---|
| An entry the source does not have was ticked | unknown-entry |
| An entry that cannot be imported was ticked | entry-unavailable |
| More than 500 entries were ticked | too-many-mocks |
| The ticked responses add up to more than 16 MiB | bodies-too-large |
| An entry cannot be saved as a mock | invalid-mock |
| A choice about overlapping examples no longer holds, such as one naming an unticked example | resolution-invalid |
| Combined examples hold more than 50 different responses | too-many-responses |
The detail then states the first error and ends Preview the import to see every problem. The preview lists every one, and says This plan cannot be applied yet.
issues lists where the source failed, at most 50: a problem in the text has a line and column, a problem in the content a pointer, the JSON Pointer of where it is. The others are null. An error in the plan has no issues. code is budget-exhausted when reading took too long, transcript-ambiguous for curl output that does not show where it ends, and the plan’s error otherwise; it is absent for the other problems in the source.
{ "type": "https://mockhub.dev/problems/import-invalid", "title": "Import cannot be read", "status": 422, "detail": "This source cannot be imported: Only curl commands can be imported; this line runs something else (line 5, column 1).", "issues": [ { "message": "Only curl commands can be imported; this line runs something else", "pointer": null, "line": 5, "column": 1 } ]}No problem quotes a value from the source: it names a line, a field or a key.
What to do
Section titled “What to do”- Fix the source where
issuespoints, or export it again. - For curl output, run the commands with
-i, so each response states where it ends, or export the requests as a HAR. - When reading took too long, import fewer entries at a time.
- For an error in the plan, preview again, untick what the preview names, and apply the new plan.