Skip to content

Conversation

HarshMN2345
Copy link
Member

@HarshMN2345 HarshMN2345 commented Sep 11, 2025

What does this PR do?

Update status code badge coloring so client errors (4xx) are orange and server errors (5xx) remain red across Functions Executions and Sites Logs (tables and sheets).

Test Plan

image

Related PRs and Issues

(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)

Have you read the Contributing Guidelines on issues?

yes

Summary by CodeRabbit

  • New Features
    • Status badges now use three levels across Executions and Site Logs: 5xx = Error, 4xx = Warning, 2xx–3xx = Success; 0 remains unclassified.
    • Consistent behavior applied in both detail views and tables for functions and sites.
    • Visual indicators updated to reflect the new mapping without altering other UI elements.

Copy link

appwrite bot commented Sep 11, 2025

Console

Project ID: 688b7bf400350cbd60e9

Sites (2)
Site Status Logs Preview QR
 console-qa
688b7cf6003b1842c9dc
Building Building View Logs Preview URL QR Code
 console-cloud
688b7c18002b9b871a8f
Queued Queued View Logs Preview URL QR Code

Note

Appwrite has a Discord community with over 16 000 members.

Copy link
Contributor

coderabbitai bot commented Sep 11, 2025

Walkthrough

The PR updates status-to-badge mappings across four Svelte components:

  • Functions executions (sheet and table): responseStatusCode mapping changed to >=500 → 'error', 400–499 → 'warning', 0 → undefined, else → 'success'.
  • Sites logs (sheet and table): mapping changed to >=500 → 'error', 400–499 → 'warning', else → 'success'.
    In executions sheet, the first check uses optional chaining (selectedLog?.responseStatusCode >= 500) while subsequent checks access the property directly. No other logic or structure is modified, and no exported/public entity signatures change.

Pre-merge checks (3 passed)

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title accurately and succinctly captures the primary change — showing 4xx status codes as warnings (orange) in Functions and Sites — and matches the badge-mapping edits described in the file summaries for both tables and sheets.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.

✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-SER-365-Change-4xx-status-code-badge-orange

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (6)
src/routes/(console)/project-[region]-[project]/sites/site-[site]/logs/sheet.svelte (2)

102-106: Remove redundant optional chaining in guarded block

Inside {#if selectedLog}, selectedLog is non-null. Drop ?. for consistency.

-        type={selectedLog?.responseStatusCode >= 500
+        type={selectedLog.responseStatusCode >= 500

102-106: Handle status code 0 consistently (neutral/no type) or confirm it can't occur for Sites

Functions executions views treat 0 as neutral (type undefined). Sites views currently map it to 'success'. Align or confirm the product difference is intentional.

-              : 'success'} />
+              : selectedLog.responseStatusCode === 0
+                ? undefined
+                : 'success'} />
src/routes/(console)/project-[region]-[project]/functions/function-[function]/executions/table.svelte (1)

99-105: De-duplicate status→badge mapping via a small helper

This ternary appears across 4 files. Centralize to avoid drift.

Add once (e.g., src/lib/helpers/httpStatus.ts):

export type BadgeType = 'success' | 'warning' | 'error' | undefined;
export const statusCodeToBadgeType = (code?: number): BadgeType =>
  code == null || code === 0 ? undefined : code >= 500 ? 'error' : code >= 400 ? 'warning' : 'success';

Then apply here:

-    type={log.responseStatusCode >= 500
-        ? 'error'
-        : log.responseStatusCode >= 400
-          ? 'warning'
-          : log.responseStatusCode === 0
-            ? undefined
-            : 'success'}
+    type={statusCodeToBadgeType(log.responseStatusCode)}

And import:

import { statusCodeToBadgeType } from '$lib/helpers/httpStatus';
src/routes/(console)/project-[region]-[project]/sites/site-[site]/logs/table.svelte (2)

90-94: Add 0→neutral case for parity with Functions, or confirm 0 never appears for Sites

Without this, 0 shows as 'success' here but neutral elsewhere.

-            : log.responseStatusCode >= 400
-              ? 'warning'
-              : 'success'}
+            : log.responseStatusCode >= 400
+              ? 'warning'
+              : log.responseStatusCode === 0
+                ? undefined
+                : 'success'}

90-94: Prefer shared helper to keep mappings consistent

If you add statusCodeToBadgeType, replace the ternary here too:

-  type={log.responseStatusCode >= 500 ? 'error' : log.responseStatusCode >= 400 ? 'warning' : 'success'}
+  type={statusCodeToBadgeType(log.responseStatusCode)}
src/routes/(console)/project-[region]-[project]/functions/function-[function]/executions/sheet.svelte (1)

101-107: Drop optional chaining; the block already guards selectedLog

Keeps the condition set consistent and slightly cleaner.

-    type={selectedLog?.responseStatusCode >= 500
+    type={selectedLog.responseStatusCode >= 500
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7ba5bfd and d921768.

📒 Files selected for processing (4)
  • src/routes/(console)/project-[region]-[project]/functions/function-[function]/executions/sheet.svelte (1 hunks)
  • src/routes/(console)/project-[region]-[project]/functions/function-[function]/executions/table.svelte (1 hunks)
  • src/routes/(console)/project-[region]-[project]/sites/site-[site]/logs/sheet.svelte (1 hunks)
  • src/routes/(console)/project-[region]-[project]/sites/site-[site]/logs/table.svelte (1 hunks)
🔇 Additional comments (3)
src/routes/(console)/project-[region]-[project]/functions/function-[function]/executions/table.svelte (2)

99-105: LGTM: Correct 5xx→error, 4xx→warning, 0→neutral mapping

Matches the PR intent and improves UX differentiation.


99-105: Confirm Badge.type supports 'warning' and undefined

Verified — Pink's Tag/Badge supports a "warning" state and the type prop is optional (omitting it renders a neutral badge).

src/routes/(console)/project-[region]-[project]/functions/function-[function]/executions/sheet.svelte (1)

101-107: LGTM: Mapping matches table view and PR intent

5xx→error, 4xx→warning, 0→neutral, else→success looks good.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should just make a helper function in order to handle this. too may ternary ops and readability issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants