All Articles

Troubleshooting Basics #1: Search the Error Message

This page has been machine-translated from the original page.

Introduction

While using a Python web application framework, I ran into the following error.

Error details:
django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:

ERRORS:
auth.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'User.groups'.
        HINT: Add or change a related_name argument to the definition for 'User.groups' or 'User.groups'.
auth.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'User.user_permissions'.
        HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'User.user_permissions'.
mocrat_user.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'User.groups'.
        HINT: Add or change a related_name argument to the definition for 'User.groups' or 'User.groups'.
mocrat_user.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'User.user_permissions'.
        HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'User.user_permissions'.

System check identified 4 issues (0 silenced).

In the end, the cause was very basic: I had configured a custom user, but I had forgotten to set AUTH_USER_MODEL in Settings.

By the way, the fix was simply to add the following line to Settings.py.

AUTH_USER_MODEL = 'AppName.ClassName'

This error turned out to be a perfect sample for explaining the basics of troubleshooting, so in this article I will use it to explain a basic troubleshooting approach.

This is a summary of basic ways to search and think when an error occurs.

Read the error message first

Now then, the first step in troubleshooting is this: do not resist it—read the error message first.

Compilers and interpreters are very smart, so for minor problems, just reading the error message is often enough to resolve the issue.
For example, in Python, you might see output like the following when an error occurs.

print(100 + "Hello")

Traceback (most recent call last):
File "stdin", line 1, in module
TypeError: unsupported operand type(s) for +: 'int' and 'str'

First, right below the traceback, the location that caused the error is shown.
In this example, it looks like the problem is on line 1.

Next, the reason for the error is written there.

TypeError: unsupported operand type(s) for +: 'int' and 'str'
So it says that addition between int and str types is not supported.

In this example, just by reading that, you can tell that the error happened because 100 was not enclosed in quotation marks.

Search the error message

Now, let’s look again at the error message quoted at the beginning.

There is a lot written there, but it does not mention the file name or the line number that caused the error.

Also, the message SystemCheckError: System check identified some issues appears to be related to the cause, but it is not obvious what it means.

Error details:

django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:

ERRORS:
auth.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'User.groups'.
        HINT: Add or change a related_name argument to the definition for 'User.groups' or 'User.groups'.
auth.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'User.user_permissions'.
        HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'User.user_permissions'.
mocrat_user.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'User.groups'.
        HINT: Add or change a related_name argument to the definition for 'User.groups' or 'User.groups'.
mocrat_user.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'User.user_permissions'.
        HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'User.user_permissions'.

System check identified 4 issues (0 silenced).

At times like this, copy and paste the error message into a search engine.

In that case, if you paste the whole thing, the search may not work well, so narrow it down to about one sentence.

Also, try to use a part that does not include the names of files you created yourself.

In this case, mocrat_user is the name of a file I created myself, so I made sure not to include that part in the search.
This is because if the name of a custom file is included in the search terms, it can become noise and keep you from getting the results you want.

So let’s search for it.

First, I searched for SystemCheckError: System check identified some issues.

Let’s start by opening the top three articles.

The contents were completely different.

In the first article, SystemCheckError was caused by a failed MEDIA_URL setting, the second article was about missing admin.py settings, and the last one was about the migration mechanism.

From this, we can infer that SystemCheckError is probably not tied to one specific phenomenon, but is instead a generic message used for errors.

Narrow down the cause and search again

In the previous section, we learned that SystemCheckError seems to be output for a variety of different cases.

Because of that, I want to change the search terms, but before doing that I first need to narrow down the cause of the problem.
In this case, because the error message does not include a file name, and based on the results of searching for SystemCheckError, I could guess that the cause might be a mistake in a configuration file or permissions.

Also, from the details of the error, it looks very likely that the problem is related to the User model.
Specifically, there was a note about a Reverse accessor.

At this point, let’s search for the sentence Reverse accessor for 'User.groups' clashes with reverse accessor for 'User.groups'.

This time, all of the top results were articles about the same problem.
That looked very promising.

That turned out to be the correct answer: even though I had defined a custom user, I had not written AUTH_USER_MODEL, so the models were conflicting.

Search by error code

This time, I was able to find the solution by searching for the error text itself, but another technique is to search by the error code.

In particular, if you are using a minor system, searching by the error text may not hit the information you want.
In that case, searching with the displayed error code can sometimes lead you to official documentation and other information related to the cause, so please give it a try.

In this case, the error code fields.E304 is displayed.

Because of that, the search term Django fields.E304 also found pages about the cause of this problem and how to fix it.

Summary

This time, I used Django troubleshooting as a theme to summarize basic knowledge such as reading error messages and how to search.

There is surprisingly little information about the troubleshooting process itself, and it often feels like a field where a lot depends on individual instinct.

If I find another good example in the future, I would like to introduce more detailed troubleshooting know-how, so please check back.