Skip to content

Commit 99303a6

Browse files
authored
Add TOC and fix heading names
1 parent 5b27ca8 commit 99303a6

File tree

1 file changed

+41
-13
lines changed

1 file changed

+41
-13
lines changed

Tutorial:-Learn-How-to-figure-out-the-reproduction-steps-for-server-error.md

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,45 @@
1-
# Tutorial: Learn How to Figure Out the Reproduction Steps for a Server Error
1+
## Table of Contents
2+
3+
- [Introduction](#introduction)
4+
* [Skills Covered](#skills-covered)
5+
* [Scenario](#scenario)
6+
- [Procedure](#procedure)
7+
+ [Setup](#setup)
8+
+ [Debugging Process](#debugging-process)
9+
* [Stage 1: Analyze the Error Logs to Locate the Affected Code](#stage-1-analyze-the-error-logs-to-locate-the-affected-code)
10+
+ [Understanding the Stack Trace](#understanding-the-stack-trace)
11+
* [Stage 2: Examine the Affected Code](#stage-2-examine-the-affected-code)
12+
* [Stage 3: Investigate Potential Causes by Exploring the Code in Depth](#stage-3-investigate-potential-causes-by-exploring-the-code-in-depth)
13+
+ [Investigating the Source of the Problem](#investigating-the-source-of-the-problem)
14+
+ [Verify the Return Type by Analyzing the Code](#verify-the-return-type-by-analyzing-the-code)
15+
* [Stage 4: Reproduce the Error](#stage-4-reproduce-the-error)
16+
- [Option 1: Reproduce on a Local Server](#option-1-reproduce-on-a-local-server)
17+
- [Option 2: Use Unit Tests](#option-2-use-unit-tests)
18+
- [Option 3: Write a Validation Job](#option-3-write-a-validation-job)
19+
- [Option 4: Add Logging for Detailed Insight](#option-4-add-logging-for-detailed-insight)
20+
+ [General Rule for Choosing an Verifying Option](#general-rule-for-choosing-an-verifying-option)
21+
* [Stage 5: Document Your Findings](#stage-5-document-your-findings)
22+
+ [Start with a Summary of the Error](#start-with-a-summary-of-the-error)
23+
+ [Detail the Steps Taken to Reproduce the Error](#detail-the-steps-taken-to-reproduce-the-error)
24+
+ [Identify the Commit or PR Likely to Have Introduced the Error](#identify-the-commit-or-pr-likely-to-have-introduced-the-error)
25+
+ [Explain the Possible Root Causes](#explain-the-possible-root-causes)
26+
+ [Suggest Next Steps](#suggest-next-steps)
27+
- [Conclusion](#conclusion)
28+
* [Tidy Up](#tidy-up)
29+
* [We Value Your Feedback](#we-value-your-feedback)
230

331
## Introduction
432

533
This tutorial will guide you through debugging a server error that is challenging to reproduce locally. Specifically, we will investigate and fix a `TypeError` related to certificate generation for contributors.
634

7-
### Skills Covered:
35+
### Skills Covered
836

937
- Codebase Navigation
1038
- Identifying and Analyzing Error Logs
1139
- Debugging Techniques
1240
- Reproducing Server Errors Locally
1341

14-
### Scenario:
42+
### Scenario
1543

1644
One of the server admins has reported the following error logs. Your task is to investigate the issue and determine how and why it is occurring.
1745

@@ -39,13 +67,13 @@ Traceback (most recent call last):
3967
TypeError: expected string or bytes-like object
4068
```
4169

42-
## Procedure:
70+
## Procedure
4371

4472
The following steps illustrate how a developer might tackle this issue. Try following this tutorial step-by-step on your local machine! This will give you a better sense of how to tackle other similar issues in the codebase. If you get stuck with a step in this tutorial, raise an issue in GitHub Discussions to get help.
4573

4674
**Important**: When you see a “practice question box”, stop and try to figure out the answer on your own before reading ahead. You will learn more if you try to figure out your own answer to the question first!
4775

48-
#### Setup:
76+
#### Setup
4977

5078
**Install Oppia on Your Local Machine**
5179
To begin, you'll need to have Oppia installed on your local machine. If you haven't done so already, please follow the installation steps provided in this [wiki page](https://github.com/oppia/oppia/wiki).
@@ -66,7 +94,7 @@ git log -1
6694

6795
The output should display the commit ID `192f0a9a4866debac160015bc949130aaae6a7fe`.
6896

69-
#### Debugging Process:
97+
#### Debugging Process
7098

7199
When faced with a server error, developers at Oppia typically follow these steps:
72100

@@ -109,7 +137,7 @@ Traceback (most recent call last):
109137
TypeError: expected string or bytes-like object
110138
```
111139

112-
#### Understanding the Stack Trace:
140+
#### Understanding the Stack Trace
113141

114142
A **stack trace** is a report of the active stack frames at a certain point in time during the execution of a program. It shows the call sequence leading to the point where the error occurred. Each line provides the file name, line number, and function where the error occurred.
115143

@@ -507,7 +535,7 @@ This is why `mypy` does not catch the type mismatch when a function like `_get_p
507535

508536
Once you have a hypothesis about the root cause of the issue, it's time to verify it. There are several ways you can do this:
509537

510-
##### Option 1: Reproduce on a Local Server**
538+
##### Option 1: Reproduce on a Local Server
511539

512540
Try to replicate the error on a local server by following the user journey that leads to the issue. This involves setting up a local environment, creating or modifying an exploration with rule inputs, and attempting to generate a certificate to see if the error occurs again. This method is practical and quick if you can accurately simulate user actions, but it may not always capture the exact conditions of the live environment.
513541

@@ -523,15 +551,15 @@ Modify or create unit tests to check if they trigger the same error when using t
523551

524552
**Cons**: Requires existing or easily adaptable unit tests.
525553

526-
##### Option 3: Write a Validation Job**
554+
##### Option 3: Write a Validation Job
527555

528556
Develop a Beam job to fetch all translations and check their data types, reporting any that are not strings. This approach involves creating and testing the job and then running it on a live server with the help of server admins. It's a thorough and systematic method, but it can be time-consuming and requires server-side execution.
529557

530558
**Pros**: Comprehensive and systematic.
531559

532560
**Cons**: Time-consuming and involves server-side execution.
533561

534-
##### Option 4: Write a Validation Job**
562+
##### Option 4: Add Logging for Detailed Insight
535563

536564
Insert `logging.error()` statements into the codebase to capture more detailed information when the error happens. By placing these logs around suspected areas of the code, you can gather data that helps you understand the problem better. However, this method requires reviewing server logs and might depend on waiting for the error to reoccur in production.
537565

@@ -665,15 +693,15 @@ To reproduce the error:
665693
- I ran the backend tests using `python -m scripts.run_backend_tests --test_target=core.domain.suggestion_services_test`.
666694
- The tests failed with a similar `TypeError` as observed in the production logs, confirming that the issue is reproducible locally.
667695

668-
#### Identify the Commit or PR Likely to Have Introduced the Error:
696+
#### Identify the Commit or PR Likely to Have Introduced the Error
669697
- Find the commit or PR that might have caused the issue using the Oppia wiki guide.
670698
- Mention the PR in your comment as a starting point for further investigation.
671699

672700
Example:
673701

674702
After examining recent changes, it appears that the issue might have been introduced in a PR that modified the `get_content_html` method to return `Union[str, List[str]]` instead of just a `str`. [Link to the PR](https://github.com/oppia/oppia/pull/17200/files#diff-6bff01224db1fe3047ddf87614d720deffd8efc7e3fca819408547f66926a541L2096) - Here, we are changing the return type of the get_content_html method from string to either strings/list. (It's not auto navigating, if you want to look, please check exp_domain file's line number 2096).
675703

676-
#### Explain the Possible Root Causes:
704+
#### Explain the Possible Root Causes
677705
- Describe your analysis of the potential causes.
678706
- Explain why the changes in the identified PR might have led to the error.
679707
- Provide any supporting information, such as error logs or specific observations.
@@ -682,7 +710,7 @@ Example:
682710

683711
The `get_content_html` method, which now returns `Union[str, List[str]]`, is being used in the `_get_plain_text_from_html_content_string function`. This function expects a `str`, but it sometimes receives a `List[str]`, causing a `TypeError`. The discrepancy between the expected input type (str) and the actual input type (List[str]) seems to be the root cause of the error.
684712

685-
#### Suggest Next Steps:
713+
#### Suggest Next Steps
686714
- Recommend further testing, confirming the bug with other contributors, or starting work on a fix.
687715
- Clearly outline what should happen next.
688716

0 commit comments

Comments
 (0)