[Refactor/Chore] Remove unnecessary error log when trigger endpoint returns 404 #21007

Closed
opened 2026-02-21 20:10:14 -05:00 by yindo · 0 comments
Owner

Originally created by @Mairuis on GitHub (Dec 12, 2025).

Originally assigned to: @Mairuis on GitHub.

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for refactors or chores; if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Description

Currently, in api/controllers/trigger/trigger.py, when a trigger endpoint is not found, the code logs an error before returning a 404 response:

if not response:
    logger.error("Endpoint not found for {endpoint_id}")  # This is unnecessary
    return jsonify({"error": "Endpoint not found"}), 404

A 404 (Not Found) response is a normal HTTP status for missing resources and should not be logged as an error. This creates unnecessary noise in the logs and may trigger false alerts in monitoring systems.

The code should simply return the 404 response without logging an error.

Motivation

  1. 404 is expected behavior: When a client requests a non-existent endpoint, returning 404 is the correct response - it's not an application error.
  2. Log pollution: Error-level logs should be reserved for actual errors that require attention. Logging every 404 as an error pollutes the logs and makes it harder to identify real issues.
  3. Monitoring noise: If monitoring systems are set up to alert on error logs, these unnecessary error logs can cause false alarms.
  4. Best practices: Most web frameworks and APIs do not log 404 responses at the error level.

Suggested Fix:

Either remove the logger.error line entirely, or change it to logger.debug or logger.info if logging is still desired for debugging purposes:

if not response:
    logger.debug(f"Endpoint not found for {endpoint_id}")  # Optional: for debugging
    return jsonify({"error": "Endpoint not found"}), 404

Additional Context

File location: api/controllers/trigger/trigger.py:36

Originally created by @Mairuis on GitHub (Dec 12, 2025). Originally assigned to: @Mairuis on GitHub. ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for refactors or chores; if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Description Currently, in `api/controllers/trigger/trigger.py`, when a trigger endpoint is not found, the code logs an error before returning a 404 response: ```python if not response: logger.error("Endpoint not found for {endpoint_id}") # This is unnecessary return jsonify({"error": "Endpoint not found"}), 404 ``` A 404 (Not Found) response is a normal HTTP status for missing resources and should not be logged as an error. This creates unnecessary noise in the logs and may trigger false alerts in monitoring systems. The code should simply return the 404 response without logging an error. ### Motivation 1. **404 is expected behavior**: When a client requests a non-existent endpoint, returning 404 is the correct response - it's not an application error. 2. **Log pollution**: Error-level logs should be reserved for actual errors that require attention. Logging every 404 as an error pollutes the logs and makes it harder to identify real issues. 3. **Monitoring noise**: If monitoring systems are set up to alert on error logs, these unnecessary error logs can cause false alarms. 4. **Best practices**: Most web frameworks and APIs do not log 404 responses at the error level. **Suggested Fix:** Either remove the `logger.error` line entirely, or change it to `logger.debug` or `logger.info` if logging is still desired for debugging purposes: ```python if not response: logger.debug(f"Endpoint not found for {endpoint_id}") # Optional: for debugging return jsonify({"error": "Endpoint not found"}), 404 ``` ### Additional Context File location: `api/controllers/trigger/trigger.py:36`
yindo closed this issue 2026-02-21 20:10:14 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#21007