keepcalculator

06 Numbers and Powers

Git Merge Conflicts & Lambda 200 Responses

Card No. 06·51277 · Updated · Standard formula, shown below

This guide explains two common but confusing situations: resolving Git merge conflicts and interpreting HTTP 200 responses from AWS Lambda functions. You’ll learn step-by-step methods to identify, resolve, and prevent merge conflicts, and how to read Lambda 200 responses to confirm successful execution or spot hidden issues.

What You’ll Need

  • A Git repository with a merge conflict (or a test repo to practice on)
  • Access to a terminal or Git GUI (like VS Code’s source control)
  • Basic familiarity with Git commands (commit, branch, merge)
  • For Lambda: an AWS account with a deployed Lambda function and CloudWatch Logs access

Step-by-Step: Git Merge Conflicts

  1. Trigger the merge – Run git merge <branch-name> in your terminal. Git will stop and list conflicted files. You’ll see CONFLICT (content): Merge conflict in <file>.
  2. Open a conflicted file – Use your editor. Conflict markers appear: <<<<<<< HEAD (your current branch), ======= (separator), and >>>>>>> <branch-name> (the incoming branch).
  3. Read the two versions – The section between <<<<<<< HEAD and ======= is your version. The section between ======= and >>>>>>> is the other branch’s version. Understand what each change intends.
  4. Choose or combine – Edit the file to keep one version, merge both, or write new code. Delete all conflict markers (<<<<<<<, =======, >>>>>>>) as you do.
  5. Save and stage – Save the file, then run git add <file> to mark it resolved.
  6. Complete the merge – After resolving all conflicts, run git commit. Git opens an editor with a default merge message; save and exit.
  7. Verify – Run git status to confirm clean, and git log --oneline to see the merge commit.

Step-by-Step: Lambda 200 Responses

  1. Invoke your Lambda – Use the AWS Console, CLI, or SDK. For example, aws lambda invoke --function-name my-function --payload '{}' output.txt.
  2. Check the HTTP status code – A 200 means the Lambda ran without a runtime error. But it doesn’t mean your business logic succeeded.
  3. Read the response body – Open the output file. The body is whatever your function’s return statement produced (e.g., JSON). Look for expected fields, not just a 200.
  4. Inspect CloudWatch Logs – Go to CloudWatch > Log Groups > /aws/lambda/<function-name>. Find the latest log stream. Look for REPORT lines showing duration, memory, and any ERROR lines.
  5. Check for swallowed errors – If your code catches exceptions and returns a 200 with an error message, the HTTP status is still 200. Examine the response body for error keys or messages.
  6. Test with invalid input – Send a payload that should fail validation. If you still get a 200, your error handling is masking failures.
  7. Use AWS X-Ray (optional) – Enable tracing to see subsegments and identify slow or failing downstream calls.

Common Mistakes

  • Git: Resolving with git checkout --ours or --theirs without understanding – This discards one side’s work entirely. Use only when you’re sure the other version is obsolete.
  • Git: Forgetting to remove conflict markers – If you leave <<<<<<< in the file, Git will treat it as text, causing syntax errors.
  • Lambda: Assuming 200 = success – A 200 only means the function executed without a runtime exception. Your code might have returned an error in the body.
  • Lambda: Ignoring CloudWatch logs – The response body doesn’t include console.log output. You must check logs for debugging.

Tips

  • Git: Use a visual merge tool – git mergetool opens a GUI (like kdiff3) that shows both sides side-by-side, making resolution easier.
  • Git: Commit often and pull frequently – Smaller, more frequent merges reduce conflict size and complexity.
  • Lambda: Structure your function to return a consistent JSON envelope – e.g., { "status": "success", "data": ... } so you can programmatically check for errors.
  • Lambda: Use structured logging – Log JSON with request IDs to correlate logs with specific invocations.

Troubleshooting

  • Git: Merge conflict in a file you don’t understand – Look at the commit history of that file: git log -p <file>. If still stuck, abort the merge with git merge --abort and discuss with your team.
  • Git: Conflict markers appear in a binary file – Git can’t merge binaries. Choose one version with git checkout --ours <file> or --theirs, then add and commit.
  • Lambda: 200 but no response body – Your function may have timed out or returned null. Check the REPORT line for Duration and Billed Duration; if it’s near the timeout, increase the timeout in configuration.
  • Lambda: 200 but the response is not what you expected – Verify the event payload. Use --payload with a valid JSON. Also check if there’s a Lambda@Edge or API Gateway transformation altering the response.
  • Lambda: 200 but logs show errors – Your code caught an exception and returned a 200. Add a console.error in the catch block and re-throw if appropriate.

Frequently Asked Questions

  1. Can I automate Git conflict resolution? – For simple conflicts, you can use git merge -X theirs to auto-pick the incoming branch, or -X ours for the current. But for complex conflicts, manual review is safer.
  2. Why does Git say “Automatic merge failed”? – It means there are overlapping changes that Git can’t resolve on its own. You must resolve them manually.
  3. Does a 200 from Lambda mean my function executed successfully? – It means the function ran without a runtime error. The logic inside might still have failed (e.g., database connection refused) but returned a 200 because you caught the error.
  4. How do I see the actual error in Lambda? – Check CloudWatch Logs. Look for ERROR lines, stack traces, or Task timed out messages.
  5. What is a Lambda 200 with a “FunctionError”? – This happens when your function throws an unhandled exception. The HTTP status is 200, but the response body includes "FunctionError": "Unhandled". Check the logs for the stack trace.
  6. Can I make Lambda return a non-200 status? – Yes, if you’re using API Gateway, you can map Lambda errors to HTTP status codes. But the Lambda invocation itself always returns 200 unless there’s a runtime error.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →