-
Notifications
You must be signed in to change notification settings - Fork 737
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
getting System.ArgumentNullException: Value cannot be null. (Parameter 'key') error #119
Comments
👋 Thanks for contributing @CMYaron! We will review the issue and get back to you soon. |
Hi @CMYaron I reproduced your error by setting an empty string for the 2 options:
Best! |
I am taking the value from codespace secrets
Its according to details in the example
When putting the key hardcode its working but this is not the case …
Get Outlook for iOS<https://aka.ms/o0ukef>
…________________________________
From: El Bruno ***@***.***>
Sent: Thursday, April 3, 2025 5:04:08 PM
To: microsoft/Generative-AI-for-beginners-dotnet ***@***.***>
Cc: Yaron Hakon ***@***.***>; Mention ***@***.***>
Subject: Re: [microsoft/Generative-AI-for-beginners-dotnet] getting System.ArgumentNullException: Value cannot be null. (Parameter 'key') error (Issue #119)
Hi @CMYaron<https://github.com/CMYaron>
I reproduced your error by setting an empty string for the Environment.GetEnvironmentVariable("GITHUB_TOKEN") value. Therefore there should be an error with your token.
image.png (view on web)<https://github.com/user-attachments/assets/269a9535-b8f2-48b1-a6c0-78f60f63d1e7>
2 options:
1. Please check the creation of your GH token (https://github.com/microsoft/Generative-AI-for-beginners-dotnet/tree/main/02-SetupDevEnvironment#creating-a-personal-access-token-for-github-model-access)
2. Check this code sample, where you can uncomment and show the value of the token before using it, so you can see if the key is correct (https://gist.github.com/elbruno/8593452caa9dabf45aad8bf6d1db3281)
Best!
—
Reply to this email directly, view it on GitHub<#119 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/BBCENXGGO6RFZWMBGQ7OWC32XU5VRAVCNFSM6AAAAAB2J6VYUCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONZVHEYDKMZQGY>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
[elbruno]elbruno left a comment (microsoft/Generative-AI-for-beginners-dotnet#119)<#119 (comment)>
Hi @CMYaron<https://github.com/CMYaron>
I reproduced your error by setting an empty string for the Environment.GetEnvironmentVariable("GITHUB_TOKEN") value. Therefore there should be an error with your token.
image.png (view on web)<https://github.com/user-attachments/assets/269a9535-b8f2-48b1-a6c0-78f60f63d1e7>
2 options:
1. Please check the creation of your GH token (https://github.com/microsoft/Generative-AI-for-beginners-dotnet/tree/main/02-SetupDevEnvironment#creating-a-personal-access-token-for-github-model-access)
2. Check this code sample, where you can uncomment and show the value of the token before using it, so you can see if the key is correct (https://gist.github.com/elbruno/8593452caa9dabf45aad8bf6d1db3281)
Best!
—
Reply to this email directly, view it on GitHub<#119 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/BBCENXGGO6RFZWMBGQ7OWC32XU5VRAVCNFSM6AAAAAB2J6VYUCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONZVHEYDKMZQGY>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Can you check this line ? Console.WriteLine($"GITHUB_TOKEN: {Environment.GetEnvironmentVariable("GITHUB_TOKEN")}"); And check, maybe you need to manually store the GitHub_Token. Examples below: If you're using bash: export GITHUB_TOKEN="<your-github-token-goes-here>" If you're in powershell: $Env:GITHUB_TOKEN="<your-github-token-goes-here>" If you're using Windows command prompt: set GITHUB_TOKEN=<your-github-token-goes-here> Please, try to run this and later the sample code. |
when running the sample, after adding the key to codspace i am getting this error when i run dont run:
$(String[] args) in /workspaces/Generative-AI-for-test/02-SetupDevEnvironment/src/BasicChat-01MEAI/Program.cs:line 11/workspaces/Generative-AI-for-test/02-SetupDevEnvironment/src/BasicChat-01MEAI/Program.cs(11,35): warning CS8604: Possible null reference argument for parameter 'key' in 'ApiKeyCredential.ApiKeyCredential(string key)'.
Unhandled exception. System.ArgumentNullException: Value cannot be null. (Parameter 'key')
at System.ClientModel.Internal.Argument.AssertNotNullOrEmpty(String value, String name)
at System.ClientModel.ApiKeyCredential.Update(String key)
at System.ClientModel.ApiKeyCredential..ctor(String key)
at Program.
i have the right key in the Codespaces secrets
The text was updated successfully, but these errors were encountered: