Skip to content

Add iseven#3

Open
bruj0 wants to merge 5 commits intomainfrom
feature/adding-iseven
Open

Add iseven#3
bruj0 wants to merge 5 commits intomainfrom
feature/adding-iseven

Conversation

@bruj0
Copy link
Copy Markdown
Owner

@bruj0 bruj0 commented Aug 12, 2025

No description provided.

Copilot AI review requested due to automatic review settings August 12, 2025 11:51
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new REST API endpoint /iseven that determines whether a submitted number is even or odd, returning HTTP status codes based on the result.

  • Introduces a new POST endpoint /iseven that accepts JSON input with a number field
  • Returns HTTP 200 for even numbers and HTTP 400 for odd numbers
  • Includes error handling for malformed requests

Comment thread src/main.py
return 400

except Exception as e:
logger.error(f"Error processing hello request: {str(e)}")
Copy link

Copilot AI Aug 12, 2025

Choose a reason for hiding this comment

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

Error message incorrectly references 'hello request' instead of 'iseven request'

Suggested change
logger.error(f"Error processing hello request: {str(e)}")
logger.error(f"Error processing iseven request: {str(e)}")

Copilot uses AI. Check for mistakes.
Comment thread src/main.py
if number % 2 == 0:
return 200
else
return 400
Copy link

Copilot AI Aug 12, 2025

Choose a reason for hiding this comment

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

Direct dictionary access will raise KeyError if 'number' key is missing. Consider using data.get('number') or add key validation

Suggested change
return 400
if not data or "number" not in data:
return jsonify({"error": "Missing 'number' field in JSON payload"}), 400
number = data["number"]
if number % 2 == 0:
return '', 200
else:
return '', 400

Copilot uses AI. Check for mistakes.
Comment thread src/main.py
if number % 2 == 0:
return 200
else
return 400
Copy link

Copilot AI Aug 12, 2025

Choose a reason for hiding this comment

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

[nitpick] Returning bare status codes without response body is inconsistent with other endpoints. Consider returning jsonify({'result': 'even'}) for consistency

Suggested change
return 400
return jsonify({"result": "even"}), 200
else:
return jsonify({"result": "odd"}), 400

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Copy Markdown

Docker Image Built

Image: bruj0/cicd-for-eks/ping-pong
Version: pr-3-20250812-120437
Registry: ghcr.io
Branch: feature/adding-iseven
PR: #3

Pull the image:

docker pull ghcr.io/bruj0/cicd-for-eks/ping-pong:pr-3-20250812-120437,ghcr.io/bruj0/cicd-for-eks/ping-pong:feature-adding-iseven-latest

Deploy with Helm:

helm upgrade --install ping-pong ./helm-charts/ping-pong \
  --set image.repository=bruj0/cicd-for-eks/ping-pong \
  --set image.tag=pr-3-20250812-120437

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