You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Tutorial:-Learn-How-to-figure-out-the-reproduction-steps-for-server-error.md
+41-13Lines changed: 41 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff 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)
2
30
3
31
## Introduction
4
32
5
33
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.
6
34
7
-
### Skills Covered:
35
+
### Skills Covered
8
36
9
37
- Codebase Navigation
10
38
- Identifying and Analyzing Error Logs
11
39
- Debugging Techniques
12
40
- Reproducing Server Errors Locally
13
41
14
-
### Scenario:
42
+
### Scenario
15
43
16
44
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.
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.
45
73
46
74
**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!
47
75
48
-
#### Setup:
76
+
#### Setup
49
77
50
78
**Install Oppia on Your Local Machine**
51
79
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
66
94
67
95
The output should display the commit ID `192f0a9a4866debac160015bc949130aaae6a7fe`.
68
96
69
-
#### Debugging Process:
97
+
#### Debugging Process
70
98
71
99
When faced with a server error, developers at Oppia typically follow these steps:
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.
115
143
@@ -507,7 +535,7 @@ This is why `mypy` does not catch the type mismatch when a function like `_get_p
507
535
508
536
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:
509
537
510
-
##### Option 1: Reproduce on a Local Server**
538
+
##### Option 1: Reproduce on a Local Server
511
539
512
540
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.
513
541
@@ -523,15 +551,15 @@ Modify or create unit tests to check if they trigger the same error when using t
523
551
524
552
**Cons**: Requires existing or easily adaptable unit tests.
525
553
526
-
##### Option 3: Write a Validation Job**
554
+
##### Option 3: Write a Validation Job
527
555
528
556
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.
529
557
530
558
**Pros**: Comprehensive and systematic.
531
559
532
560
**Cons**: Time-consuming and involves server-side execution.
533
561
534
-
##### Option 4: Write a Validation Job**
562
+
##### Option 4: Add Logging for Detailed Insight
535
563
536
564
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.
537
565
@@ -665,15 +693,15 @@ To reproduce the error:
665
693
- I ran the backend tests using `python -m scripts.run_backend_tests --test_target=core.domain.suggestion_services_test`.
666
694
- The tests failed with a similar `TypeError`as observed in the production logs, confirming that the issue is reproducible locally.
667
695
668
-
#### Identify the Commit or PR Likely to Have Introduced the Error:
696
+
#### Identify the Commit or PR Likely to Have Introduced the Error
669
697
- Find the commit orPR that might have caused the issue using the Oppia wiki guide.
670
698
- Mention the PRin your comment as a starting point for further investigation.
671
699
672
700
Example:
673
701
674
702
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).
675
703
676
-
#### Explain the Possible Root Causes:
704
+
#### Explain the Possible Root Causes
677
705
- Describe your analysis of the potential causes.
678
706
- Explain why the changes in the identified PR might have led to the error.
679
707
- Provide any supporting information, such as error logs or specific observations.
@@ -682,7 +710,7 @@ Example:
682
710
683
711
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 inputtype (str) and the actual inputtype (List[str]) seems to be the root cause of the error.
684
712
685
-
#### Suggest Next Steps:
713
+
#### Suggest Next Steps
686
714
- Recommend further testing, confirming the bug with other contributors, or starting work on a fix.
0 commit comments