Fossil SCM

When sync triggers an OOM, reformulate the error message into a sync message rather than emitting HTML. This is intended to address [forum:c15ec806c36935b5|bug report 2026-11-13T14:45:54Z] but it may turn out that this was a separate issue.

stephan 2026-11-16 10:27 UTC trunk
Commit 4455100420ac18b13fc05db1097b055d73b4de091f52e986f5527976ea21abeb
3 files changed +4 +12 -1 +7 -2
+4
--- src/db.c
+++ src/db.c
@@ -122,13 +122,17 @@
122122
json_err( 0, z, 1 );
123123
}
124124
else
125125
#endif /* FOSSIL_ENABLE_JSON */
126126
if( g.xferPanic && g.cgiOutput==1 ){
127
+ /* Report the error to the sync client here, before the additions
128
+ ** below which may reveal server filesystem paths. Mark the output
129
+ ** as done so that fossil_fatal() does not send a second reply. */
127130
cgi_reset_content();
128131
@ error Database\serror:\s%F(z)
129132
cgi_reply();
133
+ g.cgiOutput = 2;
130134
}
131135
if( strstr(z,"attempt to write a readonly database") ){
132136
static const char *azDbNames[] = { "repository", "localdb", "configdb" };
133137
int i;
134138
for(i=0; i<3; i++){
135139
--- src/db.c
+++ src/db.c
@@ -122,13 +122,17 @@
122 json_err( 0, z, 1 );
123 }
124 else
125 #endif /* FOSSIL_ENABLE_JSON */
126 if( g.xferPanic && g.cgiOutput==1 ){
 
 
 
127 cgi_reset_content();
128 @ error Database\serror:\s%F(z)
129 cgi_reply();
 
130 }
131 if( strstr(z,"attempt to write a readonly database") ){
132 static const char *azDbNames[] = { "repository", "localdb", "configdb" };
133 int i;
134 for(i=0; i<3; i++){
135
--- src/db.c
+++ src/db.c
@@ -122,13 +122,17 @@
122 json_err( 0, z, 1 );
123 }
124 else
125 #endif /* FOSSIL_ENABLE_JSON */
126 if( g.xferPanic && g.cgiOutput==1 ){
127 /* Report the error to the sync client here, before the additions
128 ** below which may reveal server filesystem paths. Mark the output
129 ** as done so that fossil_fatal() does not send a second reply. */
130 cgi_reset_content();
131 @ error Database\serror:\s%F(z)
132 cgi_reply();
133 g.cgiOutput = 2;
134 }
135 if( strstr(z,"attempt to write a readonly database") ){
136 static const char *azDbNames[] = { "repository", "localdb", "configdb" };
137 int i;
138 for(i=0; i<3; i++){
139
+12 -1
--- src/printf.c
+++ src/printf.c
@@ -1154,11 +1154,22 @@
11541154
cgi_reply();
11551155
}
11561156
}
11571157
else
11581158
#endif
1159
- if( g.cgiOutput==1 && g.db ){
1159
+ if( g.xferPanic && g.cgiOutput==1 ){
1160
+ /* An error while serving /xfer. Report it as a sync-protocol
1161
+ ** "error" card rather than an HTML page so that the client can
1162
+ ** show the actual message. The client does not parse the body
1163
+ ** of a non-200 reply, so the status code is left alone. The
1164
+ ** content type is likewise left as /xfer set it, so that the
1165
+ ** reply is compressed (or not) the way the client expects. */
1166
+ g.cgiOutput = 2;
1167
+ cgi_reset_content();
1168
+ @ error %F(z)
1169
+ cgi_reply();
1170
+ }else if( g.cgiOutput==1 && g.db ){
11601171
g.cgiOutput = 2;
11611172
cgi_reset_content();
11621173
cgi_set_content_type("text/html");
11631174
if( g.zLogin!=0 ){
11641175
style_set_current_feature("error");
11651176
--- src/printf.c
+++ src/printf.c
@@ -1154,11 +1154,22 @@
1154 cgi_reply();
1155 }
1156 }
1157 else
1158 #endif
1159 if( g.cgiOutput==1 && g.db ){
 
 
 
 
 
 
 
 
 
 
 
1160 g.cgiOutput = 2;
1161 cgi_reset_content();
1162 cgi_set_content_type("text/html");
1163 if( g.zLogin!=0 ){
1164 style_set_current_feature("error");
1165
--- src/printf.c
+++ src/printf.c
@@ -1154,11 +1154,22 @@
1154 cgi_reply();
1155 }
1156 }
1157 else
1158 #endif
1159 if( g.xferPanic && g.cgiOutput==1 ){
1160 /* An error while serving /xfer. Report it as a sync-protocol
1161 ** "error" card rather than an HTML page so that the client can
1162 ** show the actual message. The client does not parse the body
1163 ** of a non-200 reply, so the status code is left alone. The
1164 ** content type is likewise left as /xfer set it, so that the
1165 ** reply is compressed (or not) the way the client expects. */
1166 g.cgiOutput = 2;
1167 cgi_reset_content();
1168 @ error %F(z)
1169 cgi_reply();
1170 }else if( g.cgiOutput==1 && g.db ){
1171 g.cgiOutput = 2;
1172 cgi_reset_content();
1173 cgi_set_content_type("text/html");
1174 if( g.zLogin!=0 ){
1175 style_set_current_feature("error");
1176
+7 -2
--- src/xfer.c
+++ src/xfer.c
@@ -2958,11 +2958,14 @@
29582958
** Except, when cloning we will sometimes get an error on the
29592959
** first message exchange because the project-code is unknown
29602960
** and so the login card on the request was invalid. The project-code
29612961
** is returned in the reply before the error card, so second and
29622962
** subsequent messages should be OK. Nevertheless, we need to ignore
2963
- ** the error card on the first message of a clone.
2963
+ ** login and authorization errors on the first message of a clone.
2964
+ ** Any other error on that first message (for example, the server
2965
+ ** running out of memory) is reported, as otherwise the clone would
2966
+ ** carry on and silently produce an empty repository.
29642967
**
29652968
** Also ignore "not authorized to write" errors if this is an
29662969
** autopush following a commit.
29672970
*/
29682971
if( blob_eq(&xfer.aToken[0],"error") && xfer.nToken==2 ){
@@ -2970,11 +2973,13 @@
29702973
defossilize(zMsg);
29712974
if( (syncFlags & SYNC_IFABLE)!=0
29722975
&& sqlite3_strlike("%not authorized to write%",zMsg,0)==0 ){
29732976
autopushFailed = 1;
29742977
nErr++;
2975
- }else if( (syncFlags & SYNC_CLONE)==0 || nCycle>0 ){
2978
+ }else if( (syncFlags & SYNC_CLONE)==0 || nCycle>0
2979
+ || (sqlite3_strlike("not authorized%",zMsg,0)!=0
2980
+ && sqlite3_strlike("login failed%",zMsg,0)!=0) ){
29762981
fossil_force_newline();
29772982
fossil_print("Error: %s\n", zMsg);
29782983
blob_appendf(&xfer.err, "server says: %s\n", zMsg);
29792984
nErr++;
29802985
break;
29812986
--- src/xfer.c
+++ src/xfer.c
@@ -2958,11 +2958,14 @@
2958 ** Except, when cloning we will sometimes get an error on the
2959 ** first message exchange because the project-code is unknown
2960 ** and so the login card on the request was invalid. The project-code
2961 ** is returned in the reply before the error card, so second and
2962 ** subsequent messages should be OK. Nevertheless, we need to ignore
2963 ** the error card on the first message of a clone.
 
 
 
2964 **
2965 ** Also ignore "not authorized to write" errors if this is an
2966 ** autopush following a commit.
2967 */
2968 if( blob_eq(&xfer.aToken[0],"error") && xfer.nToken==2 ){
@@ -2970,11 +2973,13 @@
2970 defossilize(zMsg);
2971 if( (syncFlags & SYNC_IFABLE)!=0
2972 && sqlite3_strlike("%not authorized to write%",zMsg,0)==0 ){
2973 autopushFailed = 1;
2974 nErr++;
2975 }else if( (syncFlags & SYNC_CLONE)==0 || nCycle>0 ){
 
 
2976 fossil_force_newline();
2977 fossil_print("Error: %s\n", zMsg);
2978 blob_appendf(&xfer.err, "server says: %s\n", zMsg);
2979 nErr++;
2980 break;
2981
--- src/xfer.c
+++ src/xfer.c
@@ -2958,11 +2958,14 @@
2958 ** Except, when cloning we will sometimes get an error on the
2959 ** first message exchange because the project-code is unknown
2960 ** and so the login card on the request was invalid. The project-code
2961 ** is returned in the reply before the error card, so second and
2962 ** subsequent messages should be OK. Nevertheless, we need to ignore
2963 ** login and authorization errors on the first message of a clone.
2964 ** Any other error on that first message (for example, the server
2965 ** running out of memory) is reported, as otherwise the clone would
2966 ** carry on and silently produce an empty repository.
2967 **
2968 ** Also ignore "not authorized to write" errors if this is an
2969 ** autopush following a commit.
2970 */
2971 if( blob_eq(&xfer.aToken[0],"error") && xfer.nToken==2 ){
@@ -2970,11 +2973,13 @@
2973 defossilize(zMsg);
2974 if( (syncFlags & SYNC_IFABLE)!=0
2975 && sqlite3_strlike("%not authorized to write%",zMsg,0)==0 ){
2976 autopushFailed = 1;
2977 nErr++;
2978 }else if( (syncFlags & SYNC_CLONE)==0 || nCycle>0
2979 || (sqlite3_strlike("not authorized%",zMsg,0)!=0
2980 && sqlite3_strlike("login failed%",zMsg,0)!=0) ){
2981 fossil_force_newline();
2982 fossil_print("Error: %s\n", zMsg);
2983 blob_appendf(&xfer.err, "server says: %s\n", zMsg);
2984 nErr++;
2985 break;
2986

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button