Skip to content

opm: invalid character '&' in string escape code at offset #1153

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

Closed
cdjohnson opened this issue Oct 26, 2023 · 5 comments
Closed

opm: invalid character '&' in string escape code at offset #1153

cdjohnson opened this issue Oct 26, 2023 · 5 comments

Comments

@cdjohnson
Copy link
Contributor

Problem: When using versions of OPM (or OPM libraries) prior to 1.28.0 to render, validate, etc a FBC catalog that includes olm.csv.metadata that contains an alm.examples annotation or other embedded HTML or JSON, it may fail with an error such as: unmarshal error: invalid character '&' in string escape code at offset...

Details: This problem was fixed in #1094 as a result of revamping the YAML/JSON code that unmarshalls the data to go structs.

Solution: Use version 1.28.0 or later of OPM

Example error:

/usr/local/bin/opm-1.26.4 render docker.io/dummy-catalog/image:latest
2023/10/25 12:40:37 render reference "docker.io/dummy-catalog/image:latest": unmarshal error: invalid character '&' in string escape code at offset 3679 (indicated by <==)
 {"image":"docker.io/dummy-catalog/image:latest","name":"test-operator.v55.10.0","package":"test-operator","properties":[{"type":"olm.csv.metadata","value":{"annotations":{"alm-examples":"[\n  {\n    \"apiVersion\": \"test/v1\",\n    \"kind\": \"Test\",\n    \"metadata\": {\n      \"labels\": {\n        \"app.kubernetes.io/instance\": \"test\",\n        \"app.kubernetes.io/managed-by\": \"test\",\n        \"app.kubernetes.io/name\": \"test\"\n      },\n      \"name\": \"testdeploy\"\n    },\n    \"spec\": {\n      \"appVersion\": \"22.0.2\",\n      \"content_deployment_type\": \"Production\",\n      \"datasource_
 ...
@cdjohnson
Copy link
Contributor Author

@jchunkins
Copy link
Contributor

@cdjohnson can you add a real FBC catalog for replication?

@cdjohnson
Copy link
Contributor Author

Here are some simple steps to reproduce:

  1. mkdir catalog
  2. ~/tools/opm/1.30.1/opm render icr.io/cpopen/ibm-cp-automation-catalog@sha256:2a4fa724141a3bed68e03005e93f521a083791aaecc88092070bf72e9e3e4c43 > catalog/catalog.json
  3. ~/tools/opm/1.26.1/opm validate ./catalog

Result:
FATA[0000] invalid character '&' in string escape code

@grokspawn
Copy link
Contributor

Hi @cdjohnson. This sounds like an after-action or a breadcrumb for future searches. Is there an action here?

@cdjohnson
Copy link
Contributor Author

Yes, exactly. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants