Bug: Scan endpoint returns HTTP 500 Internal Server Error when table is disabled
Status: Resolved | Priority: Major | Resolution: Won't Fix
Created: 27/Nov/24 09:49
Affects Version/s: 4.0.0-alpha-1

h2. Scenario

Try to use stateless scanner a *disabled table* on REST interface.
h2. Actual result

Scan endpoint returns HTTP 500 Internal Server Error.
{code:java}
{
"servlet":"org.apache.hbase.thirdparty.org.glassfish.jersey.servlet.ServletContainer-33c2bd",
"message":"Request failed.",
"url":"/test/*",
"status":"500"
} {code}
h2. Expected result

It should NOT return HTTP 500 Internal Server Error.

(?) Probably some client error status code (4xx).
h2. How to reproduce
 * Create a new table (e.g via hbase shell, etc)
 * Disable the table
 * Try to scan the table with the [stateless scanner|https://issues.apache.org/jira/browse/HBASE-9343] REST endpoint

{code:java}
curl -v -X GET \
  -H "Accept: application/json" \
  "http://localhost:8080/test/*" 

...

< HTTP/1.1 500 Server Error

...{code}
h2. Additional information

REST server logs snippet:
{code:java}
2024-11-26T08:53:25,140 WARN  [qtp485475507-50 {}] server.HttpChannel: handleException /test/* com.fasterxml.jackson.databind.JsonMappingException: org.apache.hadoop.hbase.TableNotEnabledException: test (through reference chain: org.apache.hadoop.hbase.rest.TableScanResource$CellSetModelStream["Row"])2024-11-26T08:53:25,141 WARN  [qtp485475507-50 {}] server.HttpChannelState: unhandled due to prior sendErrorjavax.servlet.ServletException: org.apache.hbase.thirdparty.org.glassfish.jersey.server.ContainerException: com.fasterxml.jackson.databind.JsonMappingException: org.apache.hadoop.hbase.TableNotEnabledException: test (through reference chain: org.apache.hadoop.hbase.rest.TableScanResource$CellSetModelStream["Row"])


Caused by: java.io.UncheckedIOException: org.apache.hadoop.hbase.TableNotEnabledException: test	at org.apache.hadoop.hbase.client.ResultScanner$1.hasNext(ResultScanner.java:53) ~[hbase-client-4.0.0-alpha-1-SNAPSHOT.jar:4.0.0-alpha-1-SNAPSHOT]	at org.apache.hadoop.hbase.rest.TableScanResource$1$1.hasNext(TableScanResource.java:77) ~[hbase-rest-4.0.0-alpha-1-SNAPSHOT.jar:4.0.0-alpha-1-SNAPSHOT] {code}

The other scan endpoint handles this better (returns HTTP 406 - Not Acceptable):


{code:java}
curl -v -X PUT \                                                                     
  -H "Accept: application/json" \
  -H "Content-Type: text/xml" \                                 
  -d '<Scanner batch="1"/>' \
  "http://localhost:8080/test/scanner" | jq
* Host localhost:8080 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
* Connected to localhost (::1) port 8080
> PUT /test/scanner HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/8.9.1
> Accept: application/json
> Content-Type: text/xml
> Content-Length: 20
> 
} [20 bytes data]
* upload completely sent off: 20 bytes
< HTTP/1.1 201 Created
< X-Frame-Options: DENY
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< Location: http://localhost:8080/test/scanner/17327004740183794717d
< Content-Length: 0

curl -vi -X GET  -H "Accept: text/json" http://localhost:8080/test/scanner/17327004740183794717d     
* Host localhost:8080 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:8080...
* Connected to localhost (::1) port 8080
> GET /test/scanner/17327004740183794717d HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/8.9.1
> Accept: text/json
> 
* Request completely sent off
< HTTP/1.1 406 Not Acceptable
HTTP/1.1 406 Not Acceptable
< X-Frame-Options: DENY
X-Frame-Options: DENY
< X-Content-Type-Options: nosniff
X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
X-XSS-Protection: 1; mode=block
< Cache-Control: must-revalidate,no-cache,no-store
Cache-Control: must-revalidate,no-cache,no-store
< Content-Type: text/json
Content-Type: text/json
< Content-Length: 187
Content-Length: 187
< 

{
"servlet":"org.apache.hbase.thirdparty.org.glassfish.jersey.servlet.ServletContainer-1dfd5f51",
"message":"Not Acceptable",
"url":"/test/scanner/17327004740183794717d",
"status":"406"
* Connection #0 to host localhost left intact
}%                                                                                           


{code}