Skip to content

Conversation

@Nortren
Copy link
Contributor

@Nortren Nortren commented Apr 14, 2025

У нас была проблема при которой мы точно не могли определить из-за чего произошла ошибка на тайлах, и показывали сообщение о проблеме с ключом на все, сейчас мы стали использовать keyserver и понимаем статус ключа и только если у пользователя проблемы с ключом показываем ошибку.

Посмотреть код, проверить работу с разными ключами (валидный,не валидный, пустой)
Посмотреть тесты

* производить поиск на карте: определять координаты геообъектов по их названиям и названия по координатам.

Чтобы начать использовать API карт нужно получить ключ, для этого напишите на почту [email protected], далее перейдите в раздел [Быстрый старт](http://api.2gis.ru/doc/maps/ru/quickstart/).
Чтобы начать использовать API карт нужно получить ключ, для этого напишите на почту [email protected], далее перейдите в раздел [Быстрый старт](https://docs.2gis.com/ru/maps/others/rasterjs/).
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Поменял ссылку на новую доку это относится к задаче TILES-7316

if (mapContainer) {
mapContainer.appendChild(errorMessage);
} else {
console.warn('Map container with id "map" not found.');
Copy link
Contributor

Choose a reason for hiding this comment

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

Можно здесь и в src/DGGeoclicker/src/provider/CatalogApi.js (для console.error) исключения добавить, как это сделано тут

showBooklet: true,
showRouteSearch: true
showRouteSearch: true,
key: DG.config.key || 'Your API access key'
Copy link
Contributor

Choose a reason for hiding this comment

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

Этот кейс не совсем понял, тут мы только в опции геокликера ключ указываем?

// }
// }

// TODO статус код может быть throttling или blocked
Copy link
Contributor

Choose a reason for hiding this comment

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

почему это в TODO осталось, что мешает сразу все доделать? Что нужно делать в случае throttling напрмиер

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Тут правильнее было бы оставить NOTE , тротл насколько я понял когда по ключу вдруг невероятное количество запросов начнет сыпаться, он тоже будет заблокирован и по хорошему тоже ошибка должна показаться с предложением обратится к нам

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Убрал совсем

if (mapContainer) {
mapContainer.appendChild(errorMessage);
} else {
console.warn('Map container with id "map" not found.');
Copy link
Contributor

Choose a reason for hiding this comment

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

это ситуация невозможная же, если не контейнера, карта вообще не должна проинициализироваться


var validator = new DG.ApiKeyValidator(apiKey);
validator.validate(function(response) {
// TODO пока на 400 ошибку (пользователь без ключа) не показываем ошибку (на релизе уже показываем)
Copy link
Contributor

Choose a reason for hiding this comment

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

Как ты планируешь потом начать показывать ошибку? Это же нужно будет всем обновить пакет. Есть вариант сейчас все предусмотреть?

Copy link
Contributor

Choose a reason for hiding this comment

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

Да, в таких случаях должен обновляться бэкенд, а не клиентский код. Я думаю, нужно договориться с бэком, чтобы сейчас любой запрос проходил валидацию (и не возвращал 4xx).
Тогда тут будет уже боевой код.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Лена попросила так сделать с их стороны это норм поведение сейчас `Этим API не только растровые карты пользуются, контракт просто так не поменяешь.

Можете на своей стороне сделать обработку на время что 400 - это ок`

Copy link
Contributor

Choose a reason for hiding this comment

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

Предложение от Олега.
Вшить в код ключ на 2 месяца. Потом его инвалидировать.

"key": "",

"keyServer": "https://keys.api.2gis.com/public/v1/keys/",
"keyServices": "/services/tiles-raster-api",
Copy link
Contributor

@EvgenyRodygin EvgenyRodygin Apr 18, 2025

Choose a reason for hiding this comment

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

Потестил новый бэкэнд курлом. Вроде бы, работает корректно.

var validator = new DG.ApiKeyValidator(apiKey);
validator.validate(function(response) {

if (response.meta.code === 400 || !response.result.service.is_active || !response.result.is_active || response.result.service.status.code !== 'ok') {
Copy link
Contributor

Choose a reason for hiding this comment

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

А напомни, почему бишь мы проверяем именно 400 код, а не 403?
Такой ответ дает наш бэк?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Если пустой ключ отправить то он возвращает 400 и собщение о невалидном формате если я не путаю

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

@Nortren Nortren merged commit 71e438c into master Apr 28, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants