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

Implement/better warning for url length #6773

Merged
merged 13 commits into from
Apr 27, 2016
Merged
Show file tree
Hide file tree
Changes from 2 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
15 changes: 14 additions & 1 deletion src/ui/public/config/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,19 @@ export default function configDefaultsProvider() {
value: 5000,
description: 'The time in milliseconds which an information notification ' +
'will be displayed on-screen for. Setting to Infinity will disable.'
}
},
'url:warnLength': {
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't seem to be used anywhere?

value: 1900,
description: `
When the application url reaches this length we will start warning about
potential issues. Internet Explorer supports urls up to
<a href="https://support.microsoft.com/en-us/kb/208427">2,083 characters</a> long.
If IE compatibility is not important this can probably be disabled (set to 0).
`,
},
'url:limit': {
value: 2082,
Copy link
Contributor

Choose a reason for hiding this comment

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

Weren't we seeing IE fail before this point? I thought 2048 was the magic number there...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We were testing the length of the hash, I think... I trust the support doc though.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, right, that's the whole URL length... alrighty then.

description: 'When the application url reaches this length we will start to aggressively fail.',
},
};
};
22 changes: 20 additions & 2 deletions src/ui/public/state_management/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import EventsProvider from 'ui/events';
import Notifier from 'ui/notify/notifier';


export default function StateProvider(Private, $rootScope, $location) {
export default function StateProvider(Private, $rootScope, $location, config) {
var notify = new Notifier();
var Events = Private(EventsProvider);

_.class(State).inherits(Events);
Expand Down Expand Up @@ -44,7 +45,6 @@ export default function StateProvider(Private, $rootScope, $location) {
try {
return search[this._urlParam] ? rison.decode(search[this._urlParam]) : null;
} catch (e) {
var notify = new Notifier();
notify.error('Unable to parse URL');
search[this._urlParam] = rison.encode(this._defaults);
$location.search(search).replace();
Expand Down Expand Up @@ -107,6 +107,24 @@ export default function StateProvider(Private, $rootScope, $location) {
} else {
$location.search(search);
}

const urlLength = $location.absUrl().length;
const warnLength = config.get('url:warnLength');
const failLength = config.get('url:limit');

if (failLength && urlLength >= failLength) {
throw new TypeError(`
The URL has gotten too big and kibana can no longer
continue. Please refresh to return to your previous state.
`);
}

if (warnLength && urlLength >= warnLength) {
notify.warning(`
The URL has gotten big and may cause Kibana
to stop working. Please simplify the data on screen.
`);
}
};

/**
Expand Down