Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

Android REST API returns HTTP status code 404 instead of 500 on SQLiteException when querying a design document #96

Open
lasselaakkonen opened this issue Jun 10, 2017 · 0 comments
Labels

Comments

@lasselaakkonen
Copy link

Related to this: https://github.com/couchbase/couchbase-lite-android/issues/1091

When a POST query to a design document causes SQLITE_MAX_VARIABLE_NUMBER to be exceeded, CBL throws a SQLiteException and returns HTTP 404.

I would expect CBL to return HTTP 500 (or something similar), since I assume 404 should be interpreted as "design document not found" (that is how the REST API works, although documentation does not seem to mention error codes).

The same issue might also happen with design doc GET queries, but I ran in to the issue when POSTing lots of keys.

In my case, I am querying design documents and creating them when necessary, so the 404 response causes the design documents to be detected as missing. Should it be possible to rely on the 404 response to come only for missing design documents?

  at com.couchbase.lite.router.Router.start(Router.java:560)
  at com.couchbase.lite.listener.LiteServlet.service(LiteServlet.java:147)
Caused by: com.couchbase.lite.internal.database.sqlite.exception.SQLiteException: too many SQL variables (code 1): , while compiling: SELECT key, value, docid, revs.sequ ... AND revs.sequence = 'maps_1'.sequence AND docs.doc_id = revs.doc_id ORDER BY key, docid LIMIT ? OFFSET ?
  at com.couchbase.lite.internal.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
  at com.couchbase.lite.internal.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:718)
  at com.couchbase.lite.internal.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:431)
  at com.couchbase.lite.internal.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:595)
  at com.couchbase.lite.internal.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:64)
  at com.couchbase.lite.internal.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
  at com.couchbase.lite.internal.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:48)
  at com.couchbase.lite.internal.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1300)
  at com.couchbase.lite.internal.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1239)
  at com.couchbase.lite.storage.SQLiteStorageEngineBase.rawQuery(SQLiteStorageEngineBase.java:183)
  at com.couchbase.lite.store.SQLiteViewStore.runQuery(SQLiteViewStore.java:1014)
  at com.couchbase.lite.store.SQLiteViewStore.regularQuery(SQLiteViewStore.java:627)
  at com.couchbase.lite.View.query(View.java:358)
  at com.couchbase.lite.router.Router.queryDesignDoc(Router.java:2548)
  at com.couchbase.lite.router.Router.do_POST_DesignDocument(Router.java:2578)

Reproduced on Couchbase Lite for Android 1.3.1 and 1.4.0.

@djpongh djpongh added the icebox label Aug 31, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants