You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2023/01/12 18:34:51 UTC
[GitHub] [superset] cmiller96 opened a new issue, #22704: 500 'Fatal error' When Creating Dashboard Through Public API
cmiller96 opened a new issue, #22704:
URL: https://github.com/apache/superset/issues/22704
When trying to create a dashboard through the public API I get a response with a 500 status and the body is
```
{
"message": "Fatal error"
}
```
The logs show
```
2023-01-12 06:10:50,034:ERROR:root:'AnonymousUserMixin' object has no attribute '_sa_instance_state'
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/flask_appbuilder/api/__init__.py", line 86, in wraps
return f(self, *args, **kwargs)
File "/app/superset/views/base_api.py", line 113, in wraps
raise ex
File "/app/superset/views/base_api.py", line 110, in wraps
duration, response = time_function(f, self, *args, **kwargs)
File "/app/superset/utils/core.py", line 1524, in time_function
response = func(*args, **kwargs)
File "/app/superset/utils/log.py", line 245, in wrapper
value = f(*args, **kwargs)
File "/app/superset/views/base_api.py", line 83, in wraps
return f(self, *args, **kwargs)
File "/app/superset/dashboards/api.py", line 507, in post
new_model = CreateDashboardCommand(g.user, item).run()
File "/app/superset/dashboards/commands/create.py", line 45, in run
dashboard = DashboardDAO.create(self._properties, commit=False)
File "/app/superset/dao/base.py", line 126, in create
db.session.add(model)
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/scoping.py", line 163, in do
return getattr(self.registry(), name)(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/session.py", line 2023, in add
self._save_or_update_state(state)
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/session.py", line 2039, in _save_or_update_state
for o, m, st_, dct_ in mapper.cascade_iterator(
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/mapper.py", line 3098, in cascade_iterator
queue = deque(
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/relationships.py", line 1938, in cascade_iterator
tuples = state.manager[self.key].impl.get_all_pending(state, dict_)
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/attributes.py", line 1153, in get_all_pending
current_states = [
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/attributes.py", line 1154, in <listcomp>
((c is not None) and instance_state(c) or None, c)
AttributeError: 'AnonymousUserMixin' object has no attribute '_sa_instance_state'
```
#### How to reproduce the bug
docker-compose.yml
```
version: '3'
services:
redis:
image: redis
restart: always
volumes:
- redis:/data
superset:
image: apache/superset:2.0.1
restart: always
depends_on:
- redis
ports:
- "8088"
volumes:
- ${PWD}/superset_config.py:/app/pythonpath/superset_config.py
volumes:
redis:
```
superset_config.py
```
ENABLE_PROXY_FIX = True
FEATURE_FLAGS = {
"EMBEDDED_SUPERSET": True
}
SQLALCHEMY_DATABASE_URI = # My external postgres database uri. I get the same error using the internal db though.
#SECRET_KEY = # My secret key
SESSION_COOKIE_SAMESITE = None
ENABLE_PROXY_FIX = True
PUBLIC_ROLE_LIKE = "Gamma"
CORS_OPTIONS = {
'supports_credentials': True,
'allow_headers': ['*'],
'resources':['*'],
'origins': ['*']
}
WTF_CSRF_ENABLED = False
```
test.js
```
const axios = require('axios')
const SUPERSET_HOST = 'http://localhost:8088'
async function createDashboard() {
try {
const result = await axios({
url: `${SUPERSET_HOST}/api/v1/dashboard/`,
data: {
dashboard_title: 'Some Title'
},
headers: {
Authorization: 'Bearer ' + await getAuthToken()
},
method: 'post'
});
console.log(result);
} catch (err) {
console.log(err.response.status); // 500
console.log(err.response.data); // { message: 'Fatal error' }
}
}
async function getAuthToken() {
const result = await axios({
url: `${SUPERSET_HOST}/api/v1/security/login`,
data: {
"username": 'admin',
"password": 'admin',
"provider": "db",
"refresh": true
},
method: 'post'
});
return result?.data?.access_token;
}
createDashboard()
```
### Expected results
Expect dashboard to get created.
### Actual results
Get status code 500. 'Fatal error'
### Environment
- superset version: 2.0.1
- node.js version: v14.20.0
- any feature flags active: Embedded Dashboards
### Checklist
- [ X] I have checked the superset logs for python stacktraces and included it here as text if there are any.
- [ X] I have reproduced the issue with at least the latest released version of superset.
- [ X] I have checked the issue tracker for the same issue and I haven't found one similar.
### Additional context
The following code produces a 401. Could the user not be getting set from the token? I'm not performing these requests anonymously, so I don't know why I am getting the error `'AnonymousUserMixin' object has no attribute '_sa_instance_state'`.
Also it works when I use the swagger ui, but that request sends a cookie not a bearer token.
```
async function whoAmI() {
try {
const result = await axios( {
url: `${SUPERSET_HOST}/api/v1/me/`,
headers: {
Authorization: 'Bearer ' + await getAuthToken()
},
method: 'get'
} );
console.log(result);
} catch (err) {
console.log(err.response.status); // 401
console.log(err.response.data); // { message: 'Not authorized' }
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [I] 500 'Fatal error' When Creating Dashboard Through Public API [superset]
Posted by "cmiller96 (via GitHub)" <gi...@apache.org>.
cmiller96 closed issue #22704: 500 'Fatal error' When Creating Dashboard Through Public API
URL: https://github.com/apache/superset/issues/22704
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [superset] justmike1 commented on issue #22704: 500 'Fatal error' When Creating Dashboard Through Public API
Posted by "justmike1 (via GitHub)" <gi...@apache.org>.
justmike1 commented on issue #22704:
URL: https://github.com/apache/superset/issues/22704#issuecomment-1694628840
same issue here, same log output as @lekhanhtoan37
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [superset] justmike1 commented on issue #22704: 500 'Fatal error' When Creating Dashboard Through Public API
Posted by "justmike1 (via GitHub)" <gi...@apache.org>.
justmike1 commented on issue #22704:
URL: https://github.com/apache/superset/issues/22704#issuecomment-1694629149
it works only when using the swagger UI and being logged in, I believe the the token using in `/secure/login` does not work in the `/dashboard/` endpoint
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [I] 500 'Fatal error' When Creating Dashboard Through Public API [superset]
Posted by "cmiller96 (via GitHub)" <gi...@apache.org>.
cmiller96 commented on issue #22704:
URL: https://github.com/apache/superset/issues/22704#issuecomment-1789808886
I was able to get the api working by upgrading to v3.0.1
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [superset] ShaliniIruvuru commented on issue #22704: 500 'Fatal error' When Creating Dashboard Through Public API
Posted by "ShaliniIruvuru (via GitHub)" <gi...@apache.org>.
ShaliniIruvuru commented on issue #22704:
URL: https://github.com/apache/superset/issues/22704#issuecomment-1515898840
Working as Expected.Created a dashboard
Screenshots:-
![image](https://user-images.githubusercontent.com/115684419/233300368-aa380091-fa99-4e80-a6bd-51b485797258.png)
![image](https://user-images.githubusercontent.com/115684419/233300425-dd96fa1c-8723-4c97-9413-1c827b9f118e.png)
test.js:-
const axios = require('axios')
const SUPERSET_HOST = 'http://localhost:9000'
async function createDashboard() {
try {
const result = await axios({
url: `${SUPERSET_HOST}/api/v1/dashboard/`,
data: {
dashboard_title: 'New Dashboard1'
},
headers: {
Authorization: 'Bearer ' + await getAuthToken()
},
method: 'post'
});
console.log(result);
} catch (err) {
console.log(err.response.status);
console.log(err.response.data);
}
}
async function getAuthToken() {
const result = await axios({
url: `${SUPERSET_HOST}/api/v1/security/login`,
data: {
"username": 'admin',
"password": 'admin',
"provider": "db",
"refresh": true
},
method: 'post'
});
return result?.data?.access_token;
}
async function whoAmI() {
try {
const result = await axios( {
url: `${SUPERSET_HOST}/api/v1/me/`,
headers: {
Authorization: 'Bearer ' + await getAuthToken()
},
method: 'get'
} );
console.log(result);
} catch (err) {
console.log(err.response.status); // 401
console.log(err.response.data); // { message: 'Not authorized' }
}
}
createDashboard()
Output:-
[Running] node "/home/shali/AS_202/test.js"
{
status: 201,
statusText: 'CREATED',
headers: AxiosHeaders {
'x-powered-by': 'Express',
server: 'Werkzeug/2.1.2 Python/3.8.10',
date: 'Thu, 20 Apr 2023 07:53:05 GMT',
'content-type': 'application/json; charset=utf-8',
'content-length': '75',
vary: 'Accept-Encoding',
connection: 'close'
},
config: {
transitional: {
silentJSONParsing: true,
forcedJSONParsing: true,
clarifyTimeoutError: false
},
adapter: [ 'xhr', 'http' ],
transformRequest: [ [Function: transformRequest] ],
transformResponse: [ [Function: transformResponse] ],
timeout: 0,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
maxBodyLength: -1,
env: { FormData: [Function], Blob: null },
validateStatus: [Function: validateStatus],
headers: AxiosHeaders {
Accept: 'application/json, text/plain, */*',
'Content-Type': 'application/json',
Authorization: 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmcmVzaCI6dHJ1ZSwiaWF0IjoxNjgxOTc3MTg1LCJqdGkiOiI2N2QyOWY4ZC04YTI2LTQ1ZWMtYjUzZS1jZjI4Y2JiOGJkYTkiLCJ0eXBlIjoiYWNjZXNzIiwic3ViIjoxLCJuYmYiOjE2ODE5NzcxODUsImV4cCI6MTY4MTk3ODA4NX0.G-gW5rdzNmpGUp3FW29WPRV-42gN8z2G9OvCvni2DmQ',
'User-Agent': 'axios/1.3.6',
'Content-Length': '36',
'Accept-Encoding': 'gzip, compress, deflate, br'
},
url: 'http://localhost:9000/api/v1/dashboard/',
data: '{"dashboard_title":"New Dashboard1"}',
method: 'post'
},
request: <ref *1> ClientRequest {
_events: [Object: null prototype] {
abort: [Function (anonymous)],
aborted: [Function (anonymous)],
connect: [Function (anonymous)],
error: [Function (anonymous)],
socket: [Function (anonymous)],
timeout: [Function (anonymous)],
finish: [Function: requestOnFinish]
},
_eventsCount: 7,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
destroyed: false,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: false,
maxRequestsOnConnectionReached: false,
_defaultKeepAlive: true,
useChunkedEncodingByDefault: true,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
strictContentLength: false,
_contentLength: '36',
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
_closed: false,
socket: Socket {
connecting: false,
_hadError: false,
_parent: null,
_host: 'localhost',
_closeAfterHandlingError: false,
_readableState: [ReadableState],
_events: [Object: null prototype],
_eventsCount: 7,
_maxListeners: undefined,
_writableState: [WritableState],
allowHalfOpen: false,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: null,
_server: null,
parser: null,
_httpMessage: [Circular *1],
[Symbol(async_id_symbol)]: 29,
[Symbol(kHandle)]: [TCP],
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(timeout)]: null,
[Symbol(kBuffer)]: null,
[Symbol(kBufferCb)]: null,
[Symbol(kBufferGen)]: null,
[Symbol(kCapture)]: false,
[Symbol(kSetNoDelay)]: false,
[Symbol(kSetKeepAlive)]: true,
[Symbol(kSetKeepAliveInitialDelay)]: 60,
[Symbol(kBytesRead)]: 0,
[Symbol(kBytesWritten)]: 0,
[Symbol(RequestTimeout)]: undefined
},
_header: 'POST /api/v1/dashboard/ HTTP/1.1\r\n' +
'Accept: application/json, text/plain, */*\r\n' +
'Content-Type: application/json\r\n' +
'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmcmVzaCI6dHJ1ZSwiaWF0IjoxNjgxOTc3MTg1LCJqdGkiOiI2N2QyOWY4ZC04YTI2LTQ1ZWMtYjUzZS1jZjI4Y2JiOGJkYTkiLCJ0eXBlIjoiYWNjZXNzIiwic3ViIjoxLCJuYmYiOjE2ODE5NzcxODUsImV4cCI6MTY4MTk3ODA4NX0.G-gW5rdzNmpGUp3FW29WPRV-42gN8z2G9OvCvni2DmQ\r\n' +
'User-Agent: axios/1.3.6\r\n' +
'Content-Length: 36\r\n' +
'Accept-Encoding: gzip, compress, deflate, br\r\n' +
'Host: localhost:9000\r\n' +
'Connection: close\r\n' +
'\r\n',
_keepAliveTimeout: 0,
_onPendingData: [Function: nop],
agent: Agent {
_events: [Object: null prototype],
_eventsCount: 2,
_maxListeners: undefined,
defaultPort: 80,
protocol: 'http:',
options: [Object: null prototype],
requests: [Object: null prototype] {},
sockets: [Object: null prototype],
freeSockets: [Object: null prototype] {},
keepAliveMsecs: 1000,
keepAlive: false,
maxSockets: Infinity,
maxFreeSockets: 256,
scheduling: 'lifo',
maxTotalSockets: Infinity,
totalSocketCount: 1,
[Symbol(kCapture)]: false
},
socketPath: undefined,
method: 'POST',
maxHeaderSize: undefined,
insecureHTTPParser: undefined,
path: '/api/v1/dashboard/',
_ended: true,
res: IncomingMessage {
_readableState: [ReadableState],
_events: [Object: null prototype],
_eventsCount: 4,
_maxListeners: undefined,
socket: [Socket],
httpVersionMajor: 1,
httpVersionMinor: 1,
httpVersion: '1.1',
complete: true,
rawHeaders: [Array],
rawTrailers: [],
aborted: false,
upgrade: false,
url: '',
method: null,
statusCode: 201,
statusMessage: 'CREATED',
client: [Socket],
_consuming: true,
_dumped: false,
req: [Circular *1],
responseUrl: 'http://localhost:9000/api/v1/dashboard/',
redirects: [],
[Symbol(kCapture)]: false,
[Symbol(kHeaders)]: [Object],
[Symbol(kHeadersCount)]: 14,
[Symbol(kTrailers)]: null,
[Symbol(kTrailersCount)]: 0,
[Symbol(RequestTimeout)]: undefined
},
aborted: false,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
host: 'localhost',
protocol: 'http:',
_redirectable: Writable {
_writableState: [WritableState],
_events: [Object: null prototype],
_eventsCount: 3,
_maxListeners: undefined,
_options: [Object],
_ended: true,
_ending: true,
_redirectCount: 0,
_redirects: [],
_requestBodyLength: 36,
_requestBodyBuffers: [],
_onNativeResponse: [Function (anonymous)],
_currentRequest: [Circular *1],
_currentUrl: 'http://localhost:9000/api/v1/dashboard/',
[Symbol(kCapture)]: false
},
[Symbol(kCapture)]: false,
[Symbol(kBytesWritten)]: 0,
[Symbol(kEndCalled)]: true,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype] {
accept: [Array],
'content-type': [Array],
authorization: [Array],
'user-agent': [Array],
'content-length': [Array],
'accept-encoding': [Array],
host: [Array]
},
[Symbol(kUniqueHeaders)]: null
},
data: { id: 36, result: { dashboard_title: 'New Dashboard1' } }
}
[Done] exited with code=0 in 0.306 seconds
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [superset] lekhanhtoan37 commented on issue #22704: 500 'Fatal error' When Creating Dashboard Through Public API
Posted by "lekhanhtoan37 (via GitHub)" <gi...@apache.org>.
lekhanhtoan37 commented on issue #22704:
URL: https://github.com/apache/superset/issues/22704#issuecomment-1656742628
Same issue
192.168.96.1 - - [29/Jul/2023:14:24:32 +0000] "POST /superset/log/?explode=events&dashboard_id=1 HTTP/1.1" 200 20 "http://0.0.0.0:8088/dashboard/list/?pageIndex=0&sortColumn=changed_on_delta_humanized&sortOrder=desc&viewMode=table" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36"
'AnonymousUserMixin' object has no attribute '_sa_instance_state'
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1823, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1799, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "/usr/local/lib/python3.9/site-packages/flask_appbuilder/security/decorators.py", line 137, in wraps
return f(self, *args, **kwargs)
File "/app/superset/views/dashboard/views.py", line 123, in new
db.session.add(new_dashboard)
File "<string>", line 2, in add
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 2610, in add
self._save_or_update_state(state)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 2626, in _save_or_update_state
for o, m, st_, dct_ in mapper.cascade_iterator(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/mapper.py", line 3202, in cascade_iterator
queue = deque(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/relationships.py", line 1986, in cascade_iterator
tuples = state.manager[self.key].impl.get_all_pending(state, dict_)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/attributes.py", line 1399, in get_all_pending
current_states = [
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/attributes.py", line 1400, in <listcomp>
((c is not None) and instance_state(c) or None, c)
AttributeError: 'AnonymousUserMixin' object has no attribute '_sa_instance_state'
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org