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

refactor: Removes the deprecated redirect endpoint #26377

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion RESOURCES/STANDARD_ROLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
| can external metadata on Datasource | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | O |
| can save on Datasource | :heavy_check_mark: | :heavy_check_mark: | O | O |
| can get on Datasource | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | O |
| can shortner on R | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | O |
| can my queries on SqlLab | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| can log on Superset | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | O |
| can schemas access for csv upload on Superset | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | O |
Expand Down
1 change: 1 addition & 0 deletions UPDATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ assists people when migrating to a new version.
- [26636](https://github.com/apache/superset/issues/26636): Sets the `DASHBOARD_VIRTUALIZATION` feature flag to `True` by default. This feature was introduced by [21438](https://github.com/apache/superset/pull/21438) and will enable virtualization when rendering a dashboard's charts in an attempt to reduce the number of elements (DOM nodes) rendered at once. This is especially useful for large dashboards.
- [26637](https://github.com/apache/superset/issues/26637): Sets the `DRILL_BY` feature flag to `True` by default given that the feature has been tested for a while and reached a stable state.
- [26462](https://github.com/apache/superset/issues/26462): Removes the Profile feature given that it's not actively maintained and not widely used.
- [26377](https://github.com/apache/superset/pull/26377): Removes the deprecated Redirect API that supported short URLs used before the permalink feature.

### Potential Downtime

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { HTML5Backend } from 'react-dnd-html5-backend';

import { LineEditableTabs } from 'src/components/Tabs';
import { AntdModal } from 'src/components';
import fetchMock from 'fetch-mock';
import { styledMount as mount } from 'spec/helpers/theming';
import DashboardComponent from 'src/dashboard/containers/DashboardComponent';
import DeleteComponentButton from 'src/dashboard/components/DeleteComponentButton';
Expand All @@ -40,8 +39,6 @@ import { nativeFilters } from 'spec/fixtures/mockNativeFilters';
import { initialState } from 'src/SqlLab/fixtures';

describe('Tabs', () => {
fetchMock.post('glob:*/r/shortener/', {});

const props = {
id: 'TABS_ID',
parentId: DASHBOARD_ROOT_ID,
Expand Down
2 changes: 0 additions & 2 deletions superset/initialization/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ def init_views(self) -> None:
from superset.views.key_value import KV
from superset.views.log.api import LogRestApi
from superset.views.log.views import LogModelView
from superset.views.redirects import R
from superset.views.sql_lab.views import (
SavedQueryView,
SavedQueryViewApi,
Expand Down Expand Up @@ -309,7 +308,6 @@ def init_views(self) -> None:
appbuilder.add_view_no_menu(ExploreView)
appbuilder.add_view_no_menu(ExplorePermalinkView)
appbuilder.add_view_no_menu(KV)
appbuilder.add_view_no_menu(R)
appbuilder.add_view_no_menu(SavedQueryView)
appbuilder.add_view_no_menu(SavedQueryViewApi)
appbuilder.add_view_no_menu(SliceAsync)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
"""drop_url_table

Revision ID: e863403c0c50
Revises: 214f580d09c9
Create Date: 2023-12-28 16:03:31.691033

"""

# revision identifiers, used by Alembic.
revision = "e863403c0c50"
down_revision = "214f580d09c9"

from importlib import import_module

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql

module = import_module("superset.migrations.versions.2016-01-13_20-24_8e80a26a31db_")


def upgrade():
module.downgrade()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting approach



def downgrade():
module.upgrade()
op.alter_column("url", "changed_on", existing_type=sa.DATETIME(), nullable=True)
op.alter_column("url", "created_on", existing_type=sa.DATETIME(), nullable=True)
8 changes: 0 additions & 8 deletions superset/models/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,6 @@
DB_CONNECTION_MUTATOR = config["DB_CONNECTION_MUTATOR"]


class Url(Model, AuditMixinNullable):
"""Used for the short url feature"""

__tablename__ = "url"
id = Column(Integer, primary_key=True)
url = Column(Text)


class KeyValue(Model): # pylint: disable=too-few-public-methods

"""Used for any type of key-value store"""
Expand Down
1 change: 0 additions & 1 deletion superset/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
css_templates,
dynamic_plugins,
health,
redirects,
sql_lab,
tags,
)
Expand Down
74 changes: 0 additions & 74 deletions superset/views/redirects.py

This file was deleted.

17 changes: 1 addition & 16 deletions superset/views/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from collections import defaultdict
from functools import wraps
from typing import Any, Callable, DefaultDict, Optional, Union
from urllib import parse

import msgpack
import pyarrow as pa
Expand All @@ -31,7 +30,6 @@
from sqlalchemy.exc import NoResultFound
from werkzeug.wrappers.response import Response

import superset.models.core as models
from superset import app, dataframe, db, result_set, viz
from superset.common.db_query_status import QueryStatus
from superset.daos.datasource import DatasourceDAO
Expand Down Expand Up @@ -145,7 +143,7 @@ def loads_request_json(request_json_data: str) -> dict[Any, Any]:
return {}


def get_form_data( # pylint: disable=too-many-locals
def get_form_data(
slice_id: Optional[int] = None,
use_slice_data: bool = False,
initial_form_data: Optional[dict[str, Any]] = None,
Expand Down Expand Up @@ -185,19 +183,6 @@ def get_form_data( # pylint: disable=too-many-locals
json_data = form_data["queries"][0] if "queries" in form_data else {}
form_data.update(json_data)

if has_request_context():
url_id = request.args.get("r")
if url_id:
saved_url = db.session.query(models.Url).filter_by(id=url_id).first()
if saved_url:
url_str = parse.unquote_plus(
saved_url.url.split("?")[1][10:], encoding="utf-8"
)
url_form_data = loads_request_json(url_str)
# allow form_date in request override saved url
url_form_data.update(form_data)
form_data = url_form_data

form_data = {k: v for k, v in form_data.items() if k not in REJECTED_FORM_DATA_KEYS}

# When a slice_id is present, load from DB and override
Expand Down
11 changes: 0 additions & 11 deletions tests/integration_tests/core_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,17 +413,6 @@ def test_cache_logging(self):
db.session.delete(ck)
app.config["STORE_CACHE_KEYS_IN_METADATA_DB"] = store_cache_keys

def test_redirect_invalid(self):
model_url = models.Url(url="hhttp://invalid.com")
db.session.add(model_url)
db.session.commit()

self.login(username="admin")
response = self.client.get(f"/r/{model_url.id}")
assert response.headers["Location"] == "/"
db.session.delete(model_url)
db.session.commit()

@with_feature_flags(KV_STORE=False)
def test_kv_disabled(self):
self.login(username="admin")
Expand Down
1 change: 1 addition & 0 deletions tests/integration_tests/tags/commands_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def test_delete_tags_command(self):
TaggedObject.object_id == example_dashboard.id,
Tag.type == TagType.custom,
)
.order_by(Tag.name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this change have to do with the redirect logic?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing. It was something I caught while running the tests. It's a flaky test given that order is not guaranteed.

.all()
)
assert example_tags == [tag.name for tag in created_tags]
Expand Down
Loading