Success and errors
Check an API result, display validation messages, and handle HTTP errors and session changes.
Recognize a successful response
The common OrionMarketplace backend API envelope has three fields. Confirm success only when all three checks below pass.
200–299— The HTTP request completed successfully.success_message !== null && success_message !== ''— A non-empty success message was returned.form_errors === null— The backend returned no form errors.
{
"form_errors": null,
"success_message": "OK",
"page_data": {}
}This is an example envelope. The contents of page_data depend on the endpoint; it may also be null. Do not compare the message with “OK”: its text is translated and can vary.
A missing, null or empty success message does not confirm success. Do not show a completed action in that case. Errors take priority even if a success message is also present. Missing form_errors is an invalid envelope, not the same as null.
Display form errors
The OrionMarketplace backend can return validation and business errors with HTTP 200. Always inspect the JSON envelope before reading the result or showing a success notification.
{
"form_errors": {
"email": [
{
"message": "Enter a valid email address.",
"code": "invalid"
}
],
"__all__": [
{
"message": "Correct the highlighted fields.",
"code": ""
}
]
},
"success_message": null,
"page_data": null
}form_errors.email- Show each message next to its corresponding input.
form_errors.__all__- Show these messages above the form or in the action result.
Each field contains an array of message/code objects. Keep every message, render it as plain text, and preserve the user’s input. Codes may be empty; never use translated message text as a machine-readable condition.
HTTP statuses
These statuses are verified in the OrionMarketplace backend’s API handlers and middleware. The same status can have several causes. Some middleware and server responses are HTML or plain text instead of the common JSON envelope.
| Status | What happened | What to do |
|---|---|---|
200 | The request reached the API; validation, locale configuration or upload errors may still be present in form_errors. | Apply the success checks above. Show field and general errors when present. |
401 | The request has no signed-in session. An endpoint that requires authentication answers with page_data.auth: false. The backend also answers 401 and deletes the session and CSRF cookies when it no longer accepts the customer’s session for this storefront. | If the application still shows a signed-in customer, the session has ended: remove the profile and account data, then reload Application Load for the guest session. Do not repeat the request or open sign-in automatically; offer sign-in through an explicit user action. |
403 | Access to the request is forbidden. Check connection settings and request permissions. API endpoints also answer 403 with page_data.csrf: false when the CSRF check fails. | If page_data.csrf is false, treat it as a CSRF rejection: renew the token and let the customer retry explicitly. Otherwise check connection settings and request permissions. |
404 | The route or requested file was not found. For example, unavailable ticket attachments return a plain-text 404. | Check the target from current API discovery and whether the resource still exists. |
419 | The OrionMarketplace backend’s CSRF check rejected a request to a Django view. The JSON response includes page_data.csrf: false and issues a CSRF cookie. API endpoints report the same failure as 403. | Read the current CSRF cookie and let the user retry explicitly. Renew it if needed; do not replay mutations automatically. |
452 | The lang query parameter is not enabled for this marketplace. | Select an available language from Application Load’s locale data and correct the request. |
453 | The project’s API request allowance was exceeded where the quota check is enabled. | Check the project’s allowance in the personal account. Stop repeated requests and verify the action’s state before another attempt. |
500 | An uncaught server error interrupted processing. Caught endpoint exceptions can instead appear as form_errors with HTTP 200. | Show a temporary failure. Keep the user’s input and report the endpoint, time and status without cookies or private response data. |
The current quota middleware checks the allowance after the endpoint has run. A 453 response does not prove that a write was cancelled. Confirm its outcome before retrying.
Gateway and network failures
502 / 503 — The storefront gateway (app/api/[...orionplace]/route.ts) answers 502 when it cannot connect to OrionMarketplace and 503 when the connection settings are missing or invalid. Handle these separately from form errors.
A failed connection has no HTTP response. Handle unreadable JSON and unexpected content types separately too. Keep the status when available and never assume every error body follows the API envelope.
When to show an error page
Replace the page when its essential data cannot be loaded. An unavailable backend is not an empty product collection and does not mean that the requested page is missing.
| Situation | Display | Recovery |
|---|---|---|
Application Load fails: a connection error or timeout, a non-successful HTTP status, form errors, or an invalid response. Required initialization data under | 503Service unavailable page. | Stop page initialization. Offer an explicit retry; do not automatically open sign-in or repeatedly retry on navigation. |
The local route does not exist, or a successfully initialized application confirms that the requested product, category or other page resource is absent. | 404Page not found. | Offer a link to the homepage. A failed Application Load request must not become a false 404. |
An unexpected rendering error prevents the page from working. | 500Page error. | Show a neutral message and a reload action. Keep stack traces, backend addresses and response contents out of the visible message. |
A cart, wishlist, sign-in or another user action fails while the surrounding page remains usable. | Error beside the action or its form. | Preserve the input. Request sign-in for an explicit protected action when authentication is required; do not replace the whole page. |
Application Load succeeds, but an optional collection is empty, a translation is missing, or a preview has no suitable product. | The component’s empty state or fallback. | Keep the rest of the page available. A failed optional request can have its own retry control. |
This website uses a full error page for failed initialization of pages that need backend data. Its Retry button reloads the same address, including the query and fragment.
The server sends 503 with Cache-Control: private, no-store; a failed browser navigation shows the same error view.
Error handling, setup, type and endpoint references, and the Application Load overview remain accessible without initialization. A later failed form request does not activate this page.
The React starter keeps an Application Load failure in useOrionplace(selectFailure), and useOrionplace(selectStatus) is error. Every storefront page is then replaced by the localized error page with HTTP 503 and a Retry button (proxy.ts sets the status); an unknown address keeps its 404 page. The table above describes when a storefront should replace its page instead of showing an error beside a component.
stores/orionplace.tsRenewal, errors and session changes
Renew the CSRF cookie
POST /api/csrf_renew — send an empty JSON object through the same-origin gateway to obtain or renew the CSRF cookie, then read its current value. Renewal does not sign the customer in.
419 · page_data.csrf === false — this is the backend’s CSRF-rejection response. Accept any replacement response cookie, renew if necessary, then offer an explicit retry. Do not automatically repeat payments, orders or other mutations.
403 — a forbidden response can also mean insufficient permissions or a rejected origin. Do not treat every forbidden response as an expired CSRF token.
After sign-in or sign-out
reset() → await refresh() — after the backend confirms sign-in or sign-out, call reset() and await refresh() from useOrionplaceAppLoad(): the data and methods reload for the new session.
stores/orionplace.ts — reset and refresh change application data. They do not log the customer in or out and do not delete the browser’s cookies.
When a session ends during a request
In the React starter the shared client in lib/orionplace/api.ts checks every request it sends, including CSRF renewal, and reacts to HTTP 401 as shown below.
| Condition / action | What happens |
|---|---|
HTTP 401 while useOrionplace(selectIsAuthenticated) is true | The customer's session has ended. The client calls the store's endSession() once. The failed request reports its error and is not repeated; no sign-in dialog opens. |
| Data removed at once | Before the request reports its error, the store removes the profile (useOrionplace(selectProfile)), the signed-in methods (page_data.auth.paths), init.wallet, the counters c_cart_positions and c_wishlist, and the account values of known products: whishlist_id, subscription_id and cart_counts. The header shows Login, and its counters show a dash. |
| Guest Application Load | The public storefront data stays on screen while Application Load reloads for the guest session; useOrionplace(selectStatus) remains success meanwhile. The response replaces the data with the guest session's counters, products and endpoints. |
| Current page | Components that read the store show their guest state. An account page shows a short message instead of its section and does not navigate on its own. The next navigation to an account page opens /profile with the current page in redirect. |
| Several requests answer 401 | The first response starts the guest Application Load. Later responses find a guest store and change nothing. |
| HTTP 401 for a guest | An ordinary request error; the store is unchanged. Offer sign-in through an explicit user action. |
| HTTP 403, CSRF rejection or network failure | Ordinary request errors. The session and the signed-in data remain unchanged. |
| The guest Application Load fails | The removed data does not return. useOrionplace(selectStatus) becomes error with the details in useOrionplace(selectFailure), and pages offer Retry. |