Skip to content

Commit 76e0671

Browse files
renetapopovaLojjs
andauthored
Update readme to include guidelines for writing/updating errors (#81)
Cherry-picked from #73 & #80 --------- Co-authored-by: Louise Söderström <[email protected]>
1 parent 69df8f6 commit 76e0671

File tree

1 file changed

+215
-85
lines changed

1 file changed

+215
-85
lines changed

README.adoc

Lines changed: 215 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
This repository contains the AsciiDoc and other sources to build the link:{docs-uri}/status-codes[Neo4j Status Codes].
66

7-
7+
[[local-build]]
88
== Installation
99

1010
To build these docs locally you will need link:https://nodejs.org/en/download/package-manager/[Node & NPM^] installed.
@@ -16,7 +16,7 @@ To install the dependencies run:
1616
npm install
1717
----
1818

19-
19+
[[live-preview]]
2020
== Live Preview
2121

2222
To preview the docs, run:
@@ -30,42 +30,31 @@ This will build a set of HTML files in `build/site` and then serve them through
3030
The start script will also listen for changes and automatically rebuild the files automatically.
3131
You will still need to refresh the page to view the changes.
3232

33-
33+
[[contributing]]
3434
== Contributing
3535

3636
To make changes to this repository, please create a fork of this repo and a new branch to stage your changes.
37-
Your branch should be prefixed with the version number, for example `4.3-new-examples`.
37+
Your branch should be prefixed with the version number, for example, `dev-new-examples`.
3838

3939
When you are finished with your changes push the branch to your fork and create a Pull Request.
4040
Please add at least one approver.
4141

42-
== Guidelines for writing Neo4j notifications
43-
44-
When you want to add a new Notification code, you update the `neo4j` repo and this repo `docs-status-codes` by adding the notification details and examples.
45-
Each notification comprises the following components, some of which are documented only here in this repo.
42+
[[guidelines]]
43+
== Guidelines for writing errors and notifications
4644

47-
|===
48-
| Code| Neo.ClientNotification.Statement.CartesianProduct
49-
| Title|This query builds a cartesian product between disconnected patterns.
50-
| SeverityLevel| INFORMATION
51-
| Category| PERFORMANCE
52-
(For all categories and severity levels, see https://github.com/neo4j/docs-status-codes/blob/dev/modules/ROOT/pages/notifications/index.adoc)
53-
| Description |(Causes, consequences, a simple solution, or a reference to the Status Codes documentation)
54-
| Example| (Status Codes documentation only)
55-
| Suggestions for improvement| (Status Codes documentation only)
56-
|===
57-
58-
The following are guidelines on how to write each of the notification components.
45+
The new errors and notifications are written in the `neo4j` repo and then added to this repo `docs-status-codes` by adding the notification or error details and examples.
5946

47+
[[general-guidelines]]
6048
=== General guidelines
6149

62-
* Regardless of the notification category, each notification should include all the components.
63-
* Always use Present Simple tense (it refers to an action or event that happens regularly or to facts, general realities, and unchanging situations) and active voice (when the subject of the sentence is the one doing the action, see https://www.merriam-webster.com/words-at-play/active-vs-passive-voice-difference) if possible.
50+
* Use sentence case (you capitalize the first letter, proper nouns, and names, just like you would in a normal sentence) and punctuation.
51+
* Always use present tense and active voice (when the subject of the sentence is the one doing the action, see https://www.merriam-webster.com/words-at-play/active-vs-passive-voice-difference) if possible.
6452
* Be specific and try to use only words that count.
65-
* Avoid repeating content from other notification parts, such as title, description, code, etc.
66-
* Avoid using verbs or verb derivatives, for example, “Using”, “Running”, “The use of”, “Adding”..
53+
* Avoid repeating content from other parts, such as title, description, code, etc.
54+
* Avoid using verbs or verb derivatives, for example, “Using”, “Running”, “The use of”, “Adding”.
55+
* Do not use exclamation marks.
6756
* Avoid blaming the user.
68-
Focus the notification on the problem that could be fixed.
57+
Focus the message on the problem that could be fixed.
6958
+
7059
For example, “Did not supply query with enough parameters.“ could be rewritten to “The query does not have enough parameters”.
7160
+
@@ -75,88 +64,194 @@ It could be omitted as the title already says that it is an experimental feature
7564
* Avoid the phrase “It is recommended to” when proposing a solution.
7665
* Capitalize all Cypher keywords, i.e., `MATCH` rather than `match` or `Match`.
7766

78-
=== Code
67+
[[error-notification-components]]
68+
=== Error and notification components
7969

80-
All Neo4j codes follow the syntax `Neo.[Class].[Subclass].[Name]`.
81-
The notification codes’ [Class] is `ClientNotification`.
82-
Therefore, they all start with `Neo.ClientNotification`.
83-
The [Subclass] is one of `Statement`, `Procedure`, `Schema`, `Database`, `Security`, or `Request`.
84-
Code’s [Name] should be specific and explain what this code refers to.
70+
Each error and notification comprises the following components, some of which are documented only here in this repo.
8571

86-
✅Examples:
87-
Code: Neo.ClientNotification.Statement.RepeatedRelationshipVariableInPattern
72+
[options="header",cols="h,2,2,2"]
73+
|===
74+
| Element
75+
| More information
76+
| Notification
77+
| Error
78+
79+
| StatusCode (`Neo.[Class].[Subclass].[Name]`)
80+
| See <<statuscode-syntax, StatusCode syntax>>.
81+
| For example, `Neo.ClientNotification.Statement.CartesianProduct`.
82+
| For example, `Neo.DatabaseError.Statement.RemoteExecutionFailed`.
83+
84+
| Notification title/ Error description (Will be removed in 6.0)
85+
| See <<notification-titleerror-description, Notification title/error description>>.
86+
| For example, `This query builds a cartesian product between disconnected patterns.`
87+
| For example, `The database was unable to execute a remote part of the statement.`
88+
89+
| SeverityLevel
90+
|
91+
| One of `INFORMATION`\|`WARNING`
92+
m| ERROR
93+
94+
| Category
95+
|
96+
| One of `DEPRECATION`\|`HINT`\|`UNSUPPORTED`\|`UNRECOGNIZED`\|`SECURITY`\|`GENERIC`\|`PERFORMANCE`\|`TOPOLOGY`
97+
| N/A
98+
99+
| Notification description (Will be removed in 6.0)
100+
| See <<notification-description, Notification description>>.
101+
| Contains the main information, such as the problem, cause, consequences, and a simple solution (if possible).
102+
| N/A
103+
104+
| Message (It will replace the notification title and description, and the error description and message in 6.0.)
105+
| See <<message, Message>>.
106+
2+| Contains the main information, such as the problem, cause, consequences, a simple solution, or a reference to the Status Codes documentation.
107+
108+
| Example (only in Status Codes documentation)
109+
| See <<example, Example>>.
110+
| Contains one or more example queries to illustrate the possible scenarios when this notification would be returned.
111+
| N/A for 5.x
112+
113+
| Suggestions for improvement (only in Status Codes documentation)
114+
| See <<example, Example>>.
115+
| Contains a possible solution for the provided example query.
116+
| N/A for 5.x
117+
|===
88118

89-
⛔Examples:
90-
Code: Neo.ClientNotification.Statement.RepeatedRelationshipReference
119+
The following are guidelines on how to write each of the notification and error components.
91120

92-
=== Title
121+
[[statuscode-syntax]]
122+
==== StatusCode syntax
93123

94-
The title should be brief (one short sentence), scannable, and inform on the current situation and what code of the query triggered the notification (add it within backticks to show that it’s a code snippet).
124+
All Neo4j status codes follow the syntax `Neo.[Class].[Subclass].[Name]`.
95125

96-
* Do not use exclamation marks.
97-
* Use sentence case (you capitalize the first letter, proper nouns, and names, just like you would in a normal sentence) and punctuation.
98-
* Avoid explaining:
99-
** the consequences of the returned code.
100-
** what causes the code to be returned.
101-
** possible solutions.
126+
[options="header",cols="h,1,2,3,3,2",]
127+
|===
128+
| StatusCode
129+
| `Neo`
130+
| `[Class]`
131+
| `[Subclass]`
132+
| `[Name]`
133+
| Example
134+
135+
| Notification
136+
| `Neo`
137+
| `ClientNotification`
138+
| One of `Statement`, `Procedure`, `Schema`, `Database`, `Security`, `Cluster`, or `Request`.
139+
| Should be specific and explains what this code refers to, e.g., `ExhaustiveShortestPath`.
140+
| `Neo.ClientNotification.Statement.ExhaustiveShortestPath`
141+
142+
| Error
143+
| `Neo`
144+
| One of `ClientError`, `TransientError`, `DatabaseError`
145+
| One of `ChangeDataCapture`, `Cluster`, `Database`, `Fabric` (deprecated), `General`, `Procedure`, `Request`, `Routing`, `Schema`, `Security`, `Statement`, `Transaction`.
146+
| Should be specific and explains what this code refers to, e.g., `RemoteExecutionFailed`.
147+
| `Neo.DatabaseError.Statement.RemoteExecutionFailed`
148+
|===
102149

103-
⛔Example (contains a possible solution):
104-
The provided pattern is unbounded, consider adding an upper limit to the number of node hops.
150+
[[notification-titleerror-description]]
151+
==== Notification title/error description
105152

106-
✅Example:
107-
The pattern `<pattern>` is unbounded.
153+
The notification title and the error description contain similar information.
154+
Therefore, they follow the same guidelines.
155+
Both should be brief (one short sentence), specific, and inform on the current situation and what code of the query triggered the notification/error (add it within backticks to show that it’s a code snippet).
156+
Avoid explaining the cause, consequences, or solution.
157+
The notification title and description will be replaced by a single field `message` in 6.0.
158+
The error description in 5.x is used just as a fallback error message in some specific cases, and in 6.0, it will no longer be used.
159+
See <<message, Message>>.
108160

109-
⛔Example:
110-
This feature is deprecated and will be removed in future versions.
161+
.Examples for notification title and error description
162+
[options="header",cols="h,2,2",]
163+
|===
164+
| Example
165+
| ⛔ Don't
166+
| ✅ Do
111167

112-
✅Example:
113-
(Deprecated) The repeated variable length relationship r is bound more than once.
168+
| Notification title 1
169+
| The provided pattern is unbounded, consider adding an upper limit to the number of node hops.
170+
| The pattern `<pattern>` is unbounded.
114171

115-
⛔Example (contains a possible solution):
116-
The provided label is not in the database.
172+
| Notification title 2
173+
| The provided label is not in the database.
174+
| The label `Perso` does not exist.
175+
|===
117176

118-
✅Example:
119-
The label `Perso` does not exist.
177+
[[notification-description]]
178+
==== Notification description
120179

180+
The Notification description should contain the most important information for the user.
181+
They should be brief, scannable, specific, and contain the following details (if applicable):
121182

183+
* Cause -- what triggered the code to be returned.
184+
* Consequences -- why it might be a problem.
185+
* A simple solution if possible.
122186

123-
=== Description
187+
.Examples of notification descriptions
188+
[options="header",cols="h,2,2",]
189+
|===
190+
| Example
191+
| ⛔ Don't
192+
| ✅ Do
124193

125-
This is the description of the returned code.
194+
| Notification description 1
195+
| Using shortest path with an unbounded pattern will likely result in long execution times.
196+
It is recommended to use an upper limit to the number of node hops in your pattern.
197+
| Shortest path with an unbounded pattern may result in long execution times.
198+
Use an upper limit to the number of node hops in your pattern.
126199

127-
The description should contain the following:
200+
| Notification description 2
201+
| Using an already bound variable for a variable length relationship is deprecated and will be removed in a future version. (the repeated variable is: r)
202+
| A variable length relationship that is bound more than once does not return any result.
128203

129-
* What caused the notification to be returned
130-
* Why it might be a problem - what the consequences are
131-
* If possible, a simple solution, otherwise, a reference to the docs using the sentence:
132-
_See Status Codes documentation for suggestions for improvement._
204+
| Notification description 3
205+
| One of the labels in your query is not available in the database, make sure you didn’t misspell it or that the label is available when you run this statement in your application (the missing label name is: Perso)
206+
| Non-existing labels yield no result. Verify that the label is spelled correctly.
207+
|===
133208

209+
[[message]]
210+
==== Message
134211

135-
⛔Example:
136-
Using shortest path with an unbounded pattern will likely result in long execution times.
137-
It is recommended to use an upper limit to the number of node hops in your pattern.
212+
In 6.0, the notifications and errors will have only a message, which will be used instead of the notification title and description, and the error description and message.
138213

139-
✅Rewrite:
140-
Shortest path with an unbounded pattern may result in long execution times.
141-
Use an upper limit to the number of node hops in your pattern.
214+
The message should follow the same guidelines as the notification description, namely:
215+
216+
The message should contain the most important information for the user.
217+
It should be brief, scannable, specific, and contain the following details (if applicable):
142218

143-
⛔Example:
144-
Using an already bound variable for a variable length relationship is deprecated and will be removed in a future version. (the repeated variable is: r)
219+
* Problem -- what happened and what code of the query triggered the notification/error (add it within backticks to show that it’s a code snippet).
220+
* Cause -- what triggered the code to be returned.
221+
* A simple solution if possible.
145222

146-
✅Rewrite:
147-
A variable length relationship that is bound more than once does not return any result. See Status Codes documentation for suggestions for improvement.
223+
.Examples of error messages
224+
[options="header",cols="h,2,2",]
225+
|===
226+
| Example
227+
| ⛔ Don't
228+
| ✅ Do
148229

149-
⛔Example:
150-
One of the labels in your query is not available in the database, make sure you didn’t misspell it or that the label is available when you run this statement in your application (the missing label name is: Perso)
230+
| Error message 1
231+
| Failed to create the specified database '%s': The total limit of databases is already reached. To create more you need to either drop databases or change the limit via the config setting 'dbms.max_databases'
232+
| Failed to create the database `$param1`. The limit of databases is reached. Either increase the limit using the config setting `$param2` or drop a database.
151233

152-
✅Rewrite:
153-
Non-existing labels yield no result. Verify that the label is spelled correctly.
234+
| Error message 2
235+
| Database does not exist. Database name: '%s'
236+
| `$param` database not found. Verify that the spelling is correct.
154237

155-
=== Example
238+
| Error message 3
239+
| The allocation of an extra %s would use more than the limit %s. Currently using %s. %s threshold reached
240+
| Failed to allocate `$param1`. Currently using $param2`. Increase the memory pool limit using `$param3`.
241+
|===
242+
243+
[[example]]
244+
==== Example
245+
246+
[NOTE]
247+
====
248+
This component is currently documented only for notifications.
249+
If you are updating an error, you can skip this section.
250+
====
156251

157-
The examples and suggestions for improvement are written only in the Status Codes doc.
252+
The examples and possible solutions are written only here in this repo, for the Status Codes doc.
158253

159-
Add one or more example queries to illustrate the possible scenarios when this notification code would be returned.
254+
Add one or more example queries to illustrate the possible scenarios when this notification would be returned.
160255
They should look similar to the following:
161256

162257
.<Add a caption that explains the example>
@@ -169,29 +264,64 @@ Here write the query.
169264
----
170265
171266
Description of the returned code::
172-
Same as in the `ne4j` repo.
267+
Same as in the `neo4j` repo.
173268
174269
Suggestions for improvement::
175270
176271
Give a possible solution for the provided example query.
272+
====
177273

178-
⛔Example:
274+
For example:
275+
276+
[options="header",cols="2,2",]
277+
|===
278+
| ⛔ Don't
279+
| ✅ Do
179280

281+
a| .Cartesian product
282+
====
283+
Query::
284+
+
285+
[source, cypher, role="noplay"]
286+
----
287+
MATCH (c:Child), (p:Parent) RETURN c, p
288+
----
289+
290+
Description of the returned code::
291+
If a part of a query contains multiple disconnected patterns,
292+
this will build a cartesian product between all those parts.
293+
This may produce a large amount of data and slow down query processing.
294+
While occasionally intended, it may often be possible to reformulate the query that avoids the use of this cross product,
295+
perhaps by adding a relationship between the different parts or by using `OPTIONAL MATCH` (identifier is: (`p`))
296+
297+
Suggestions for improvement::
180298
In case a cartesian product is needed, nothing can be done to improve this query.
181299
In many cases, however, you might not need a combination of all children and parents, and that is when this query could be improved.
182300
If for example, you need the children and the children's parents, you can improve this query by rewriting it to the following:
183-
301+
+
184302
[source, cypher, role="noplay"]
185303
----
186304
MATCH (c:Child)-[:ChildOf]->(p:Parent) RETURN c, p
187305
----
306+
====
307+
a| .Cartesian product
308+
====
309+
Query::
310+
+
311+
[source, cypher, role="noplay"]
312+
----
313+
MATCH (c:Child), (p:Parent) RETURN c, p
314+
----
188315
316+
Description of the returned code::
317+
The disconnected patterns `$param` build a cartesian product. A cartesian product may produce a large amount of data and slow down query processing.
189318
190-
✅Rewrite:
191-
319+
Suggestions for improvement::
192320
If you only need the children and the children's parents, and not all combinations between them, add `[:ChildOf]` between the `Child` and the `Parent` nodes:
193321
194322
[source, cypher, role="noplay"]
195323
----
196324
MATCH (c:Child)-[:ChildOf]->(p:Parent) RETURN c, p
197-
====
325+
----
326+
====
327+
|===

0 commit comments

Comments
 (0)