Skip to content

feat: add proxy-aware clients, reports workflow, and tests#1

Open
hivrich wants to merge 2 commits intomainfrom
codex/check-data-retrieval-for-trisystems.ru
Open

feat: add proxy-aware clients, reports workflow, and tests#1
hivrich wants to merge 2 commits intomainfrom
codex/check-data-retrieval-for-trisystems.ru

Conversation

@hivrich
Copy link
Copy Markdown
Owner

@hivrich hivrich commented Dec 26, 2025

Summary

  • add HTTP helper with proxy bypass defaults for Yandex/Google APIs and wire new API clients
  • scaffold analysis modules and Makefile reports target for end-to-end data fetching
  • document setup in README and add pytest-based smoke tests for http helper and config loading

Testing

  • pytest --maxfail=1 --disable-warnings --quiet

Codex Task


Note

Adds a runnable, proxy-aware data collection scaffold and basic workflow.

  • Introduces app/http_client.py with env-driven proxy/NO_PROXY handling, default timeouts, and request_json
  • Implements API clients: metrika_client.py, ym_webmaster_client.py, gsc_client.py (env-based auth; simple list/get calls)
  • Adds analysis stubs: analysis_sources.py, analysis_pages.py, analysis_goals.py, analysis_gsc.py, analysis_ym_webmaster.py
  • Adds Makefile targets: reports (prints fetched data) and test
  • Updates README.md with setup/usage; adds docs/cursor_tasks.md for restoration tasks
  • Extends deps (requests, pytest) and adds smoke tests for HTTP helper and config loading (tests/test_http_client.py, tests/test_config.py)

Written by Cursor Bugbot for commit 3cf1a3b. This will update automatically on new commits. Configure here.

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

.PHONY: reports test

reports:
CLIENT?=partacademy
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Makefile uses Make syntax inside shell recipe

The CLIENT?=partacademy line is inside the recipe (indented with a tab), so it gets executed by the shell rather than Make. The ?= conditional assignment operator is Make syntax, not valid shell syntax. This causes make reports to fail with a shell error. The assignment needs to be at the Makefile's top level (unindented), or use shell syntax like ${CLIENT:-partacademy} inside the recipe.

Fix in Cursor Fix in Web

"api-metrika.yandex.net",
"api-metrika.yandex.ru",
"api-metrika.yandex.com",
"api.webmaster.yandex.ru",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

NO_PROXY list uses wrong domain for webmaster API

The DEFAULT_NO_PROXY_HOSTS list includes api.webmaster.yandex.ru, but ym_webmaster_client.py uses api.webmaster.yandex.net as the API endpoint. This domain mismatch means webmaster API requests will still go through the corporate proxy instead of bypassing it, likely causing the documented 403 Forbidden errors.

Additional Locations (1)

Fix in Cursor Fix in Web

_get_credentials()
session = _session()
url = f"{GSC_API}/sites"
return request_json(session, "GET", url)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

GSC client validates credentials but doesn't use them

The get_sites() function calls _get_credentials() to validate that GSC_CLIENT_ID and GSC_REFRESH_TOKEN are set, but discards the return value and makes the API request without any authentication headers. This is inconsistent with metrika_client and ym_webmaster_client which properly use their tokens. Users will be prompted to set credentials that have no effect, and the request will always fail with 401 Unauthorized from Google's API.

Fix in Cursor Fix in Web

if config.extra_no_proxy:
merged_no_proxy = _merge_no_proxy(merged_no_proxy, config.extra_no_proxy)

proxies["no_proxy"] = merged_no_proxy
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Proxy bypass via no_proxy dict key is ignored

The requests library does not honor a no_proxy key in the session.proxies dictionary - it only reads NO_PROXY from environment variables when trust_env=True. Setting proxies["no_proxy"] has no effect, so the DEFAULT_NO_PROXY_HOSTS for Yandex and Google APIs won't bypass the proxy as intended. The entire proxy bypass mechanism for these API domains is non-functional.

Additional Locations (1)

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant