Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error Unexpected token < in JSON at position 0 #18126

Closed
suraj-12 opened this issue Jan 21, 2022 · 8 comments
Closed

error Unexpected token < in JSON at position 0 #18126

suraj-12 opened this issue Jan 21, 2022 · 8 comments
Labels
#bug Bug report validation:required A committer should validate the issue

Comments

@suraj-12
Copy link

use case is to embed superset dasboards in a web application as iframe but while doing so on some visualization getting Unexpected token < in JSON at position 0 error.

normally in superset application same dashboard is working fine but while sahring as iframe only this issue is coming.

superset version 1.32

html page content for testing:

<iframe name="iframe1" src="https://xxxxxxxxxxx- ![supersetiframeerror](https://user-images.githubusercontent.com/48901138/150507033-1e215d15-2824-41f8-9e61-6e7834add800.JPG) superset.ad.infosys.com/superset/dashboard/13/" frameborder="0" marginheight="0" marginwidth="0" width="100%" height="100%" scrolling="auto"></iframe>
@suraj-12 suraj-12 added the #bug Bug report label Jan 21, 2022
@geido geido added the need:more-info Requires more information from author label Jan 24, 2022
@geido
Copy link
Member

geido commented Jan 24, 2022

Hello @suraj-12 thanks for reporting this issue. Would you please provide more information concerning those viz types for which you are experiencing this problem? Thank you!

@suraj-12
Copy link
Author

iframe issue

Facing issues in filters, metrics and pie charts

@suraj-12
Copy link
Author

but if i use same url in browser then there is no issue. only while integrating it with iframe i was getting this issue

@geido geido added validation:required A committer should validate the issue and removed need:more-info Requires more information from author labels Jan 25, 2022
@gndsnts
Copy link

gndsnts commented Jan 25, 2022

Sorry to repeat this issue, but i think is better wait for this solution, and verify if it works correctly. After confirm, i will close my issue.

@suddjian
Copy link
Member

I believe this is fixed by #17530

@thalesvon
Copy link

Hi @suddjian,

I believe this is fixed by #17530

Could you elaborate what fixed this issue on the above PR? I still have the same issue. Here is a bit more of context on my scenario.

Environment

  • AWS ECS Fargate Platform 1.3.0, superset running on Docker.
  • Superset version 1.4.1
  • Authentication OAuth with Google
  • Additional settings on superset_config.py
ENABLE_PROXY_FIX = True
PUBLIC_ROLE_LIKE_GAMMA = True

ENABLE_CORS = True
CORS_OPTIONS = {
    'supports_credentials': True,
    'allow_headers': ['*'],
    'resources':['*'],
    'origins': ['https://MY_SUPERSET.DOMAIN/','https://sites.google.com/', 'https://MY_CUSTOM_APP.DOMAIN'],
}

Use Case

I am trying to embedded Charts and Dashboard into Google Sites and my webApp.

I tried embedding using two approaches:

  1. iframe:
<iframe
  width="100%"
  height="100%"
  seamless
  frameBorder="0"
  scrolling="no"
  src="https://MY_SUPERSET.DOMAIN/superset/explore/?r=11&standalone=1"
>
</iframe>

This led to the error message on the iframe Unexpected token < in JSON at position 0.

  1. Embbeding by URL. Using the link provided by Superset on the chart explore page Copy chart URL to clipboard:

image

This also led to the error message on the iframe Unexpected token < in JSON at position 0.

image

Additional Information

  • If I open the URL on the srctag of my iframe and open I a new tab of my browser, I can see the Chart just fine, the error only apprear when the chart is embbeded.

image

  • I also tried adding EMBEDDED_SUPERSET=True to superset_config.py but that did not change anything.

Any guidance is appreciated.

@thalesvon
Copy link

For anyone interested on this thread, the error message was misleading.
I found an error on the superset logs with the message:

The CSRF session token is missing

I added the following to my superset_config.py and the iframe worked like a charm.

SESSION_COOKIE_SAMESITE = None

This issue describes the CSRF token error: #8382

@mdeshmu
Copy link
Contributor

mdeshmu commented Mar 18, 2022

@suraj-12 can you provide a documentation on how you are running superset on AWS ECS, if you have ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
#bug Bug report validation:required A committer should validate the issue
Projects
None yet
Development

No branches or pull requests

6 participants