Repository navigation
Implement ShadeClient class for per-instance configuration #2
Description
Activity
gm maintainer i will like to work on this issue
gm maintainer i can fix this issue and have the pr submitted to you by tomorrow asap
- addedGrantFox OSSIssue tracked in GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignCampaign: Official Campaign
on Jun 20, 2026 daveades commented
on Jul 27, 2026 ContributorMore actionsHi @codebestia, I'd like to work on this issue.
How I understand it
Global config works fine when there is one tenant. It breaks once one process serves many tenants, because their credentials share the same module state. So
ShadeClientshould stand on its own as a config object that resource methods use per call, with the global config only as a fallback.What I will do
- Add
src/shade/client.pywith aShadeClientdataclass holdingapi_key,environment,api_base,timeout,max_retries. - Give each resource class an optional
clientkwarg. Order per call is the passed client first, then global config, then raiseAuthenticationErrorif both are missing. No instance changes the global, so two clients stay independent. - Add a
ShadeClient.from_env()classmethod that readsSHADE_API_KEYandSHADE_ENVIRONMENT.
Tests, one for each acceptance criterion
ShadeClient(api_key="sk_test_xxx")makes an isolated client.- A resource call through that client uses its key, not the global.
- Two clients with different keys run at the same time without affecting each other.
from_env()readsSHADE_API_KEYcorrectly.- Missing
api_keywith global alsoNoneraisesAuthenticationError.
About me
I do Python backend work with Flask. I am comfortable with dataclasses and handling how config is read from the environment.
I can open a PR in 1 to 2 days.
- Add
grantfox-oss commented
on Jul 27, 2026 grantfox-ossboton Jul 27, 2026 – with GrantFox OSSMore actions- added a commit that references this issue
on Jul 30, 2026 - added a commit that references this issue
on Jul 30, 2026 grantfox-oss commented
on Jul 30, 2026 grantfox-ossboton Jul 30, 2026 – with GrantFox OSSMore actions🎉 This issue has been marked as completed on GrantFox as part of the Official Campaign | FWC26 campaign!
@daveades's PR #55 was approved and merged by @codebestia.
🏆 @daveades: You earned 35 FoxPoints for this contribution! Your current tier: Explorer (188 total points). Track your full progress on GrantFox.
👏 Great work, @daveades! Keep contributing to ShadeProtocol.
Description:
While global config is convenient, multi-tenant applications (e.g. a SaaS acting on behalf of multiple merchants) need isolated client instances that carry their own credentials.
ShadeClientshould accept the same parameters as the global config and bind them to a single instance, which is then passed to resource methods.Proposed Steps:
src/shade/client.pywith aShadeClientdataclass/class.api_key,environment,api_base,timeout,max_retries.client=kwarg and fall back to global config if omitted.ShadeClient.from_env()factory that readsSHADE_API_KEYandSHADE_ENVIRONMENTfrom environment variables.Acceptance Criteria:
client = ShadeClient(api_key="sk_test_xxx")creates an isolated client.ShadeClientinstances with different keys can coexist without interfering.ShadeClient.from_env()readsSHADE_API_KEYfrom the environment correctly.api_keyon the instance when global is alsoNoneraisesAuthenticationError.