{"record":{"id":"c17bf223797d789b","repo":"tinyhumansai/openhuman","slug":"profile-profile-id-belongs-to-provider-not","errorCode":null,"errorMessage":"Profile {profile_id} belongs to provider {}, not {}","messagePattern":"Profile (.+?) belongs to provider (.+?), not (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/openhuman/security/credentials/core.rs","lineNumber":62,"sourceCode":"    ) -> Result<AuthProfile> {\n        let mut profile = AuthProfile::new_token(provider, profile_name, token.to_string());\n        profile.metadata.extend(metadata);\n        self.store.upsert_profile(profile.clone(), set_active)?;\n        Ok(profile)\n    }\n\n    pub fn set_active_profile(&self, provider: &str, requested_profile: &str) -> Result<String> {\n        let provider = normalize_provider(provider)?;\n        let data = self.store.load()?;\n        let profile_id = resolve_requested_profile_id(&provider, requested_profile);\n\n        let profile = data\n            .profiles\n            .get(&profile_id)\n            .ok_or_else(|| anyhow::anyhow!(\"Auth profile not found: {profile_id}\"))?;\n\n        if profile.provider != provider {\n            anyhow::bail!(\n                \"Profile {profile_id} belongs to provider {}, not {}\",\n                profile.provider,\n                provider\n            );\n        }\n\n        self.store.set_active_profile(&provider, &profile_id)?;\n        Ok(profile_id)\n    }\n\n    pub fn remove_profile(&self, provider: &str, requested_profile: &str) -> Result<bool> {\n        let provider = normalize_provider(provider)?;\n        let profile_id = resolve_requested_profile_id(&provider, requested_profile);\n        self.store.remove_profile(&profile_id)\n    }\n\n    pub fn get_profile(\n        &self,","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/749120085864ce16e0f273c7b86fac7740b39c5b/src/openhuman/security/credentials/core.rs#L44-L80","documentation":"Fires in set_active_profile when the profile id resolved from the requested profile name exists in the store but is registered under a different provider than the one passed in. It is a cross-provider profile-selection guard: the caller asked to activate, e.g., provider A's named profile while the id belongs to provider B, so the activation is refused instead of silently switching a credential across providers.","triggerScenarios":"Thrown at src/openhuman/security/credentials/core.rs:62 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass the provider that actually owns the requested profile (check the profile's provider field).","Use the exact profile id together with its owning provider when selecting by id.","List profiles for the intended provider first to confirm the id/name mapping."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"749120085864ce16e0f273c7b86fac7740b39c5b","analyzedAt":"2026-08-17T21:21:45.363Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}