Skip to content
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 ##[error]Failed to parse with json file #513

Closed
mslentz opened this issue May 3, 2021 · 27 comments
Closed

Getting ##[error]Failed to parse with json file #513

mslentz opened this issue May 3, 2021 · 27 comments
Assignees
Labels
Azure Pipelines bug Something isn't working

Comments

@mslentz
Copy link

mslentz commented May 3, 2021

Hi, I'm working in Azure Gov and I'm trying to push my config json file to an App Config service and I keep getting an error:

##[error]Failed to parse: .......path to file

the file looks like this:

{
"Key1": "value"
}

I am using Azure Pipelines in our DevOps instance. The pipeline is using a service principle that has permissions to the resource group (it is successfully deploying to an app service) and has the "App Configuration Data Owner" role on the config service.

The error is a bit non-specific, do you have any ideas on what I can do to further troubleshoot this?

@shenmuxiaosen shenmuxiaosen added cli Issues relating to the App Configuration Hubs CLI. Azure Pipelines and removed cli Issues relating to the App Configuration Hubs CLI. labels May 4, 2021
@MaryanneNjeri
Copy link
Contributor

Hi @mslentz, could you share the format of your json file, which could have key and value masked and I can use the file to repro the issue?

@MaryanneNjeri
Copy link
Contributor

@mslentz, also check if the config json file contains any trailing commas, can be the cause of the error sometimes

@mslentz
Copy link
Author

mslentz commented May 4, 2021

I discovered my issue was with spaces in the path to the file. Thanks for your help.

@mslentz mslentz closed this as completed May 4, 2021
@zhenlan
Copy link
Contributor

zhenlan commented May 4, 2021

@MaryanneNjeri thanks for looking into this. Just curious, won't it work when there are spaces in the path?

@MaryanneNjeri
Copy link
Contributor

MaryanneNjeri commented May 5, 2021

I tried it on my end, if the space is present in the file path something like this $filepath /configFile.json, the error presented is
##[error]An unexpected error occurred. ENOENT: no such file or directory, open 'path to file' , but if the space is present in the file name, config File.json and the path is $filepath/config File.json it works, maybe @mslentz could confirm where the spaces were in the file path?

@mslentz
Copy link
Author

mslentz commented May 5, 2021

I did have spaces in my file path. I changed to an AZ CLI command and was able to publish a simple json file: {"Key1": "value"}

I am using this command:
az appconfig kv import -s file --format json --path $file --separator . --depth 2 --label Development --auth-mode login --endpoint https://xxxxxx --yes

I just added my actual config file:

{
"ActionCenterDiscussionFetchDays": "30",
"ActionCenterNotificationFetchDays": "14",
"AllowedHosts": "*",
"EnableHelpPage": "true",
"Logging:LogLevel:Default": "Information",
"Logging:LogLevel:Microsoft": { "Hosting": { "Lifetime": "Information" } },
"ResultReplayer": {
"Enable": "false",
"RemoveFromKey": "...."
},

"api": {
  "Password": "",
  "UserPropertyCacheLengthInMinutes": "0",
  "orgServiceUri": "https://...",
  "username": "xxxx"
},
"email": {
  "MailFrom": "xxxx",
  "SMTPServer": "xxxx",
  "SMTPServerEnableSsl": "false",
  "SMTPServerPort": "xxx",
  "SMTPServerUsername": "xxxx",
  "Support": "",
  "disableWorkerService": "false",
  "mailBody": "xxxxxxxxx",
  "mailSubject": "xxxxxxx"
},
"form2": { "version": "2" },
"form3": { "version": "2" },
"form4A": { "version": "2" },
"ida:ADFSMetadataCRMApi": "https://xxxxxx",
"ida:WtrealmCRMApi": "https://xxxxxxxx",
"owin:AutomaticAppStartup": "true",
"web": {
  "ApplicationInsights:InstrumentationKey": "xxxxx",
  "AzureKvUri": "https://xxxxxx",
  "AzureWebAppClientId": "xxxxx",
  "AzureWebAppTenantId": "xxxxx",
  "EfsapDbConnStringUrl": "xxxxxxxxxx",
  "HomeRealm": ""
}

}

and the CLI is giving an error that says: The input is not a well formatted json file. I'm not seeing the problem, can you help?

@avanigupta
Copy link
Member

@mslentz, I tried importing the exact contents of your JSON file using the same command that you are using, and I'm not getting any error. Can you try to format the file you're using with any JSON formatter and see if there's a syntax issue on your side?

@avanigupta
Copy link
Member

Thanks for bringing this to our attention @mslentz. The error turned out to be due to the presence of a non-ASCII character in the JSON file being imported. We are working on supporting the import of all unicode characters using CLI.

@zhenlan
Copy link
Contributor

zhenlan commented May 7, 2021

Great. @MaryanneNjeri, you will fix the 'space in path" issue too?

@ctvanzandt42
Copy link

I'm also having this issue without any special characters in my JSON file. When I use the Azure CLI, it lets me import with the same file, but the pipeline task throws this every time.

@MaryanneNjeri
Copy link
Contributor

@zhenlan yes I’ll work on a fix for that.

@MaryanneNjeri
Copy link
Contributor

@ctvanzandt42 it throws the error “Failed to parse: ‘... path to file’?

@ctvanzandt42
Copy link

ctvanzandt42 commented May 11, 2021

Correct; I’ve put the depth at zero, removed it, changed the separator, no dice. If I use the CLI, it imports it just fine, but the pipeline task fails with the exact JSON.

@MaryanneNjeri
Copy link
Contributor

MaryanneNjeri commented May 11, 2021

@ctvanzandt42 , could you share your json file, which could have key and value masked and I can use the file to reproduce the issue?

@ctvanzandt42
Copy link

ctvanzandt42 commented May 11, 2021

Sure! So here's how I'm using the task:

  displayName: 'Push Configuration'
  inputs:
    azureSubscription: '<service principal here>'
    ConfigstoreName: '<config name served by Terraform>'
    ConfigurationFile: 'configuration.json'
    Separator: ':'
    Depth: '2'
    Strict: false

And my JSON looks like this:

{
  "member-info-cb5ad5d2-722a-46e6-9159-dcb23cd39621-someKey": "32494824",
  "member-info-cb5ad5d2-722a-46e6-9159-dcb23cd39621-someOtherKey": "234324,234234,234234"
}

Values are not accurate obviously, and I'm also purposely not using hyphens as the separator. Right now, I'm just trying to get these two KV pairs pushed, I can flatten properly later.

@MaryanneNjeri
Copy link
Contributor

MaryanneNjeri commented May 11, 2021

@ctvanzandt42 I tried using your json file with the azure app configuration push task, it succeeded on my end
73260A47-506A-4890-A8A0-FD0900B44A60
Could try check if the json file has no syntax issues?

@ctvanzandt42
Copy link

Can you share how the task looks? That is the exact JSON I'm pushing, with a few strings substituted. Again, it's valid JSON and it works pushing from the CLI.

@MaryanneNjeri
Copy link
Contributor

Yes let me share how the task looks like from my end.

@MaryanneNjeri
Copy link
Contributor

MaryanneNjeri commented May 12, 2021

Task version: 1.3.4
Display Name: 'azure app config task'
inputs:
azureSubscription: 'service principal '
ConfigstoreName: 'config store name’
Configuration file path: 'config1.json'
Separator: ':'
Depth: '2'
Strict: false

@MaryanneNjeri MaryanneNjeri reopened this May 12, 2021
@zhenlan zhenlan added the bug Something isn't working label May 12, 2021
@ctvanzandt42
Copy link

Hey Maryanne, that's exactly how the task looks on my end. Very weird; I ended up doing this manually, which is obviously not ideal for production, but had to be done. I'd love to revisit this if you all find there's a bug in here, I'm happy to help you all battle-test this if need be.

@MaryanneNjeri
Copy link
Contributor

@ctvanzandt42 will definitely reach out if we find a bug. Please feel free to reach out incase of anything.

@MaryanneNjeri
Copy link
Contributor

Hi, @ctvanzandt42 a new release is out for Azure App Configuration Task version - 3.5.16 and Azure App Configuration Push Task version-1.4.4, with the fix that gives more information about the error message above, please feel free to check it out. In case of any questions please feel free to reach out :).

Thanks,
Maryanne

@ctvanzandt42
Copy link

Wonderful, Maryanne! Let me know when the release notes are posted, I don't see them. Looking forward to implementing the fix.

@MaryanneNjeri
Copy link
Contributor

Awesome will let you know once the release notes are posted.

@MaryanneNjeri
Copy link
Contributor

@ctvanzandt42 the release notes for this fix were posted, AzureDevOpspipelineExtension and AzureDevOpsPushPipelineExtension

@zhenlan
Copy link
Contributor

zhenlan commented Oct 4, 2021

@MaryanneNjeri can this be closed?

@mslentz
Copy link
Author

mslentz commented Oct 4, 2021

@MaryanneNjeri can this be closed?

Yes, thank you so much!

@zhenlan zhenlan closed this as completed Oct 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Azure Pipelines bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants