|
| 1 | +## HTTP endpoints |
| 2 | + |
| 3 | +The following HTTP endpoints are exposed: |
| 4 | + |
| 5 | +### GET `/api/listing/` |
| 6 | + |
| 7 | +Serves submitted bug reports. Protected by basic HTTP auth using the |
| 8 | +username/password provided in the environment. A browsable list, collated by |
| 9 | +report submission date and time. |
| 10 | + |
| 11 | +A whole directory can be downloaded as a tarball by appending the parameter `?format=tar.gz` to the end of the URL path |
| 12 | + |
| 13 | +### POST `/api/submit` |
| 14 | + |
| 15 | +Submission endpoint: this is where applications should send their reports. |
| 16 | + |
| 17 | +The body of the request should be a multipart form-data submission, with the |
| 18 | +following form field names. (For backwards compatibility, it can also be a JSON |
| 19 | +object, but multipart is preferred as it allows more efficient transfer of the |
| 20 | +logs.) |
| 21 | + |
| 22 | +* `text`: A textual description of the problem. Included in the |
| 23 | + `details.log.gz` file. |
| 24 | + |
| 25 | +* `user_agent`: Application user-agent. Included in the `details.log.gz` file. |
| 26 | + |
| 27 | +* `app`: Identifier for the application (eg 'riot-web'). Should correspond to a |
| 28 | + mapping configured in the configuration file for github issue reporting to |
| 29 | + work. |
| 30 | + |
| 31 | +* `version`: Application version. Included in the `details.log.gz` file. |
| 32 | + |
| 33 | +* `label`: Label to attach to the github issue, and include in the details file. |
| 34 | + |
| 35 | + If using the JSON upload encoding, this should be encoded as a `labels` field, |
| 36 | + whose value should be a list of strings. |
| 37 | + |
| 38 | +* `log`: a log file, with lines separated by newline characters. Multiple log |
| 39 | + files can be included by including several `log` parts. |
| 40 | + |
| 41 | + If the log is uploaded with a filename `name.ext`, where `name` contains only |
| 42 | + alphanumerics, `.`, `-` or `_`, and `ext` is one of `log` or `txt`, then the |
| 43 | + file saved to disk is based on that. Otherwise, a suitable name is |
| 44 | + constructed. |
| 45 | + |
| 46 | + If using the JSON upload encoding, the request object should instead include |
| 47 | + a single `logs` field, which is an array of objects with the following |
| 48 | + fields: |
| 49 | + |
| 50 | + * `id`: textual identifier for the logs. Used as the filename, as above. |
| 51 | + * `lines`: log data. Newlines should be encoded as `\n`, as normal in JSON). |
| 52 | + |
| 53 | + A summary of the current log file formats that are uploaded for `log` and |
| 54 | + `compressed-log` is [available](docs/submitted_reports.md). |
| 55 | + |
| 56 | +* `compressed-log`: a gzipped logfile. Decompressed and then treated the same as |
| 57 | + `log`. |
| 58 | + |
| 59 | + Compressed logs are not supported for the JSON upload encoding. |
| 60 | + |
| 61 | + A summary of the current log file formats that are uploaded for `log` and |
| 62 | + `compressed-log` is [available](docs/submitted_reports.md). |
| 63 | + |
| 64 | +* `file`: an arbitrary file to attach to the report. Saved as-is to disk, and |
| 65 | + a link is added to the github issue. The filename must be in the format |
| 66 | + `name.ext`, where `name` contains only alphanumerics, `-` or `_`, and `ext` |
| 67 | + is one of `jpg`, `png`, `txt`, `json`, `txt.gz` or `json.gz`. |
| 68 | + |
| 69 | + Not supported for the JSON upload encoding. |
| 70 | + |
| 71 | +* Any other form field names are interpreted as arbitrary name/value strings to |
| 72 | + include in the `details.log.gz` file. |
| 73 | + |
| 74 | + If using the JSON upload encoding, this additional metadata should insted be |
| 75 | + encoded as a `data` field, whose value should be a JSON map. (Note that the |
| 76 | + values must be strings; numbers, objects and arrays will be rejected.) |
| 77 | + |
| 78 | +The response (if successful) will be a JSON object with the following fields: |
| 79 | + |
| 80 | +* `report_url`: A URL where the user can track their bug report. Omitted if |
| 81 | + issue submission was disabled. |
| 82 | + |
| 83 | +## Error responses |
| 84 | + |
| 85 | +The rageshake server will respond with a specific JSON payload when encountering an error. |
| 86 | + |
| 87 | +```json |
| 88 | +{ |
| 89 | + "error": "A human readable error string.", |
| 90 | + "errcode": "UNKNOWN", |
| 91 | + "policy_url": "https://github.com/matrix-org/rageshake/blob/master/docs/blocked_rageshake.md" |
| 92 | +} |
| 93 | +``` |
| 94 | + |
| 95 | +Where the fields are as follows: |
| 96 | + |
| 97 | + - `error` is an error string to explain the error, in English. |
| 98 | + - `errcode` is a machine readable error code which can be used by clients to give a localized error. |
| 99 | + - `policy_url` is an optional URL that links to a reference document, which may be presented to users. |
| 100 | + |
| 101 | +### Error codes |
| 102 | + |
| 103 | +- `UNKNOWN` is a catch-all error when the appliation does not have a specific error. |
| 104 | +- `METHOD_NOT_ALLOWED` is reported when you have used the wrong method for an endpoint. E.g. GET instead of POST. |
| 105 | +- `DISALLOWED_APP` is reported when a report was rejected due to the report being sent from an unsupported |
| 106 | + app (see the `allowed_app_names` config option). |
| 107 | +- `BAD_HEADER` is reported when a header was not able to be parsed, such as `Content-Length`. |
| 108 | +- `CONTENT_TOO_LARGE` is reported when the reported content size is too large. |
| 109 | +- `BAD_CONTENT` is reported when the reports content could not be parsed. |
| 110 | +- `REJECTED` is reported when the submission could be understood but was rejected by `rejection_conditions`. |
| 111 | + This is the default value, see below for more information. |
| 112 | + |
| 113 | +In addition to these error codes, the configuration allows application developers to specify specific error codes |
| 114 | +for report rejection under the `REJECTED_*` namespace. (see the `rejection_conditions` config option). Consult the |
| 115 | +administrator of your rageshake server in order to determine what error codes may be presented. |
0 commit comments