prisma graphql token fails to verify when deployed in heroku - heroku

I have deployed a Graphql Yoga Server in Heroku using a Prisma service as Database and I have also deploy the frontend which is a nextjs app on Heroku as well. When I try to perform a upsert operation using the prisma db connection, it fails saying [GraphQL error]: Message: Your token is invalid. It might have expired or you might be using a token from a different project., Location: undefined, Path: undefined. I have gone through similar issues on Prisma's Github issues, couldn't find anything helpful.
prisma_db connection:
const db = new Prisma({
typeDefs: 'src/generated/prisma.graphql',
endpoint: process.env.PRISMA_ENDPOINT,
secret: process.env.PRISMA_SECRET,
debug: true,
});
prisma.yml:
endpoint: ${env:PRISMA_ENDPOINT}
datamodel: datamodel.prisma
secret: ${env:PRISMA_SECRET}
# disableAuth: true
hooks:
post-deploy:
- graphql get-schema -p prisma
I have set the PRISMA_ENDPOINT and PRISMA_SECRET in the Heroku config vars. To make sure both the .yml file and the DB connection have the same secret token. I have also set the secret token to be something relatively simple, consider secret123, so that there are no special characters as well.
Entire Error:
2018-12-21T07:08:45.107583+00:00 app[web.1]: [GraphQL error]: Message: Your token is invalid. It might have expired or you might be using a token from a different project., Location: undefined, Path: undefined
2018-12-21T07:08:45.108037+00:00 app[web.1]: [Network error]: Error: Your token is invalid. It might have expired or you might be using a token from a different project.
2018-12-21T07:08:45.115464+00:00 app[web.1]: { Error: Your token is invalid. It might have expired or you might be using a token from a different project.
2018-12-21T07:08:45.115467+00:00 app[web.1]: at BatchedGraphQLClient.<anonymous> (/app/node_modules/http-link-dataloader/dist/src/BatchedGraphQLClient.js:69:35)
2018-12-21T07:08:45.115469+00:00 app[web.1]: at step (/app/node_modules/http-link-dataloader/dist/src/BatchedGraphQLClient.js:40:23)
2018-12-21T07:08:45.115471+00:00 app[web.1]: at Object.next (/app/node_modules/http-link-dataloader/dist/src/BatchedGraphQLClient.js:21:53)
2018-12-21T07:08:45.115472+00:00 app[web.1]: at fulfilled (/app/node_modules/http-link-dataloader/dist/src/BatchedGraphQLClient.js:12:58)
2018-12-21T07:08:45.115474+00:00 app[web.1]: at process._tickCallback (internal/process/next_tick.js:68:7)
2018-12-21T07:08:45.115476+00:00 app[web.1]: message:
2018-12-21T07:08:45.115478+00:00 app[web.1]: 'Your token is invalid. It might have expired or you might be using a token from a different project.',
2018-12-21T07:08:45.115480+00:00 app[web.1]: locations: [],
2018-12-21T07:08:45.115482+00:00 app[web.1]: path: [ 'upsertUser' ] }
For info: when I try to perform the same upsert operation from the Prisma playground, it works fine. Can someone please tell me where I am going wrong? Thanks in advance.

Related

How resolve -API call error https://a.blazemeter.com/api/latest/proxy: {'code': 401, 'message': 'Unauthorized'}

I have one selenium script. Now I want it to convert into a JMX file. Here I used the proxy2jmx converter. I also created an account in Blazemeter. I have one token and a secret key, those values provide in the .bzt-rc file.
Now I provide one config yml file -
execution:
executor: selenium
iterations: 1
scenario: sel
scenarios:
sel:
script: F:\Taurus\HelloSelenium.java
services:
module: proxy2jmx
modules:
proxy2jmx:
token: 707ab10114456ad7af13827f
When execute this file It return Error message-->11:21:24 ERROR: Network Error: API call error https://a.blazemeter.com/api/latest/proxy: {'code': 401, 'message': 'Unauthorized'}
11:21:24 INFO: Post-processing...
11:21:24 INFO: Will not pick converted JMX due to exception: API call error https://a.blazemeter.com/api/latest/proxy: {'code': 401, 'message': 'Unauthorized'}
How is it resolved?
I think the correct way of providing token is
modules:
blazemeter:
token: 756a1345d1c8258a739dd260:1c2f53d2612dc64cb4c9dade311f351916b9e391330c9f6d1a2e1e36da76cabc44be9ce6
More information:
BlazeMeter Reporting Service - Personalized Usage
BlazeMeter API keys

Apollo CLIError: Error in "Loading schema for Unnamed Project"

I am trying to get api-types for the project that is running Apollo server since years. But now when I run command apollo client:codegen api-types --includes=src/**/*.tsx --endpoint=http://localhost:4000/graphql --target=typescript --globalTypesFile=src/api-types/globalTypes.ts I get below error:
Warning: apollo update available from 2.33.4 to 2.33.9.
⠸ Loading Apollo Project
Generating query files
CLIError: Error in "Loading schema for Unnamed Project": Error: ServerError: Response not successful: Received status code 500
at Object.error (/workApp/node_modules/#oclif/errors/lib/index.js:26:15)
at Generate.error (/workApp/node_modules/#oclif/command/lib/command.js:60:23)
at OclifLoadingHandler.showError (/workApp/node_modules/apollo/lib/OclifLoadingHandler.js:29:22)
at OclifLoadingHandler.handle (/workApp/node_modules/apollo/lib/OclifLoadingHandler.js:14:18)
at processTicksAndRejections (internal/process/task_queues.js:97:5) {
oclif: { exit: 2 },
✖ Loading Apollo Project
→ Error initializing Apollo GraphQL project "Unnamed Project": Error:
…
Generating query files
› Error: Error initializing Apollo GraphQL project "Unnamed Project":
› Error: Error in "Loading schema for Unnamed Project": Error:
› ServerError: Response not successful: Received status code 500
I looked a few Stackoveflow posts and tried this command too: apollo schema:download --endpoint=http://localhost:4000/graphql schema.json
But that also gives me below error:
✔ Loading Apollo Project
✖ Saving schema to schema.json
→ ServerError: Response not successful: Received status code 500
Error: ServerError: Response not successful: Received status code
500
Any suggestion to fix this error?
Along with your endpoint url ,if needed pass Authorization token in the header options .

Connect to Heroku redis from a nestjs app

I am hosting my nestjs application on Heroku and trying to use "Heroku redis" add-on with it.
In the app.module.ts I am importing RedisModule as follows:
#Module({
imports: [
RedisModule.register({ host: process.env.REDIS_URL })
]
})
After configuring Heroku-redis add-on, it added REDIS_URL under config vars in Heroku, however, when I deploy and run the application, I get the following error message:
2020-06-11T09:00:48.690255+00:00 app[web.1]: [ioredis] Unhandled error event: Error: getaddrinfo ENOTFOUND redis://h:abc#ec2-52-51-206-63.eu-west-1.compute.amazonaws.com:16719
(I've replaced the real url value with a sample one to illustrate the problem)
I can't seem to find
RedisModule.register({ url: process.env.REDIS_URL })

meanjs 0.4.0 not working when deployed to Heroku

I've just tried the meanjs 0.4.0 in local host and runs fine but when I deploy to heroku link to app and try the "Sign up" option I get this in the navegator console:
POST https://meanjsapptest.herokuapp.com/api/auth/signup 503 (Service Unavailable)
and when I write the comand heroku logs in the CLI I get:
2017-06-06T04:15:35.152983+00:00 app[web.1]: (node:16) DeprecationWarning: Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead: http://mongoosejs.com/docs/promises.html
2017-06-06T04:15:35.153005+00:00 app[web.1]: crypto.js:635
2017-06-06T04:15:35.153006+00:00 app[web.1]: throw new TypeError(
2017-06-06T04:15:35.153006+00:00 app[web.1]: ^
2017-06-06T04:15:35.153007+00:00 app[web.1]:
2017-06-06T04:15:35.153008+00:00 app[web.1]: TypeError: The "digest" argument is required and must not be undefined
2017-06-06T04:15:35.153009+00:00 app[web.1]: at pbkdf2 (crypto.js:635:11)
2017-06-06T04:15:35.153010+00:00 app[web.1]: at Object.exports.pbkdf2Sync (crypto.js:628:10)
2017-06-06T04:15:35.153012+00:00 app[web.1]: at model. (/app/modules/users/server/models/user.server.model.js:112:26)
2017-06-06T04:15:35.153011+00:00 app[web.1]: at model.UserSchema.methods.hashPassword (/app/modules/users/server/models/user.server.model.js:123:19)
2017-06-06T04:15:35.153013+00:00 app[web.1]: at _next (/app/node_modules/hooks-fixed/hooks.js:62:30)
2017-06-06T04:15:35.153013+00:00 app[web.1]: at fnWrapper (/app/node_modules/hooks-fixed/hooks.js:186:8)
2017-06-06T04:15:35.153014+00:00 app[web.1]: at model. (/app/node_modules/mongoose/lib/plugins/saveSubdocs.js:20:7)
2017-06-06T04:15:35.153014+00:00 app[web.1]: at _next (/app/node_modules/hooks-fixed/hooks.js:62:30)
2017-06-06T04:15:35.153015+00:00 app[web.1]: at fnWrapper (/app/node_modules/hooks-fixed/hooks.js:186:8)
2017-06-06T04:15:35.153015+00:00 app[web.1]: at /app/node_modules/mongoose/lib/plugins/validateBeforeSave.js:33:13
2017-06-06T04:15:35.153016+00:00 app[web.1]: at /app/node_modules/kareem/index.js:131:16
2017-06-06T04:15:35.153016+00:00 app[web.1]: at _combinedTickCallback (internal/process/next_tick.js:95:7)
2017-06-06T04:15:35.153017+00:00 app[web.1]: at process._tickCallback (internal/process/next_tick.js:161:9)
2017-06-06T04:15:35.167579+00:00 app[web.1]: error: Forever detected script exited with code: 1
2017-06-06T04:15:35.173500+00:00 app[web.1]: error: Script restart attempt #1
2017-06-06T04:15:35.292903+00:00 app[web.1]:
2017-06-06T04:15:35.294191+00:00 app[web.1]:
2017-06-06T04:15:35.310954+00:00 app[web.1]: + Error: Certificate file or key file is missing, falling back to non-SSL mode
2017-06-06T04:15:35.311037+00:00 app[web.1]: To create them, simply run the following from your shell: sh ./scripts/generate-ssl-certs.sh
2017-06-06T04:15:35.311039+00:00 app[web.1]:
2017-06-06T04:15:35.916892+00:00 app[web.1]: Db.prototype.authenticate method will no longer be available in the next major release 3.x as MongoDB 3.6 will only allow auth against users in the admin db and will no longer allow multiple credentials on a socket. Please authenticate using MongoClient.connect with auth credentials.
I don't know what to do now because Heroku supports tell me thar the error is in my code but I haven't changed anything there!
CLI screenshot
Just had this problem. We were able to fix it by enforcing our preferred node version in package.json > engines.
We previously had it at
"node": ">=0.10.0"
We changed it to
"node": "6.6.0"
And then pushed that to Heroku, and that fixed the issue.
Not entirely sure what the problem is, but we found this link which lead us to believe the node version was the issue:
https://github.com/nodejs/node/wiki/Breaking-changes-between-v4-LTS-and-v6-LTS#crypto

Installing cloudfoundry gives Authentication error with Openstack; How can I debug an Opensource project? Namely, bosh on Openstack?

I am trying to create a Bosh Microinstance on my Rackspace Server and am getting the following error:
E, [2013-10-29T15:17:25.113723 #30341] [0xc9c00c] ERROR -- : Unable to connect to the OpenStack Compute API. Check task debug log for details.
I, [2013-10-29T16:38:36.928221 #1754] [0x335004] INFO -- : No existing deployments found (will save to /root/bosh-deployments.yml)
I, [2013-10-29T16:39:14.636310 #1768] [0xfa9010] INFO -- : Loading existing deployment data from: /root/bosh-workspace/deployments/bosh-deployments.yml
I, [2013-10-29T16:39:20.766583 #1768] [0xfa9010] INFO -- : bosh-registry is ready on port 25889
I, [2013-10-29T16:39:26.731953 #1768] [0xfa9010] INFO -- : Loading yaml from /tmp/d20131029-1768-ewe5t0/sc-20131029-1768-ansv2l/stemcell.MF
E, [2013-10-29T16:39:28.626135 #1768] [0xfa9010] ERROR -- : Expected([200, 204]) <=> Actual(401 Unauthorized)
response => #<Excon::Response:0x0000000382cdc0 #data={:body=>"{\"unauthorized\":{\"code\":401,\"message\":\"Unable to authenticate user with credentials provided.\"}}", :headers=>{"Server"=>"nginx/0.8.55", "Date"=>"Tue, 29 Oct 2013 16:39:27 GMT", "Content-Type"=>"application/json", "Transfer-Encoding"=>"chunked", "Connection"=>"keep-alive", "vary"=>"Accept, Accept-Encoding, X-Auth-Token", "VIA"=>"1.0 Repose (Repose/2.3.5)"}, :status=>401, :remote_ip=>"72.3.138.129"}, #body="{\"unauthorized\":{\"code\":401,\"message\":\"Unable to authenticate user with credentials provided.\"}}", #headers={"Server"=>"nginx/0.8.55", "Date"=>"Tue, 29 Oct 2013 16:39:27 GMT", "Content-Type"=>"application/json", "Transfer-Encoding"=>"chunked", "Connection"=>"keep-alive", "vary"=>"Accept, Accept-Encoding, X-Auth-Token", "VIA"=>"1.0 Repose (Repose/2.3.5)"}, #status=401, #remote_ip="72.3.138.129"> (Excon::Errors::Unauthorized)
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/excon-0.25.3/lib/excon/middlewares/expects.rb:10:in `response_call'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/excon-0.25.3/lib/excon/middlewares/response_parser.rb:8:in `response_call'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/excon-0.25.3/lib/excon/connection.rb:349:in `response'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/excon-0.25.3/lib/excon/connection.rb:247:in `request'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/fog-1.14.0/lib/fog/core/connection.rb:57:in `request'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/fog-1.14.0/lib/fog/core/deprecated/connection.rb:20:in `request'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/fog-1.14.0/lib/fog/openstack.rb:195:in `retrieve_tokens_v2'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/fog-1.14.0/lib/fog/openstack.rb:88:in `authenticate_v2'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/fog-1.14.0/lib/fog/openstack/compute.rb:392:in `authenticate'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/fog-1.14.0/lib/fog/openstack/compute.rb:316:in `initialize'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/fog-1.14.0/lib/fog/core/service.rb:68:in `new'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/fog-1.14.0/lib/fog/core/service.rb:68:in `new'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/fog-1.14.0/lib/fog/compute.rb:44:in `new'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/bosh_openstack_cpi-1.5.0.pre.1181/lib/cloud/openstack/cloud.rb:55:in `initialize'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/bosh_cpi-1.5.0.pre.1181/lib/cloud/provider.rb:11:in `new'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/bosh_cpi-1.5.0.pre.1181/lib/cloud/provider.rb:11:in `create'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/bosh_cli_plugin_micro-1.5.0.pre.1181/lib/bosh/deployer/configuration.rb:65:in `cloud'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/bosh_cli_plugin_micro-1.5.0.pre.1181/lib/bosh/deployer/instance_manager.rb:54:in `cloud'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/bosh_cli_plugin_micro-1.5.0.pre.1181/lib/bosh/deployer/instance_manager.rb:229:in `block (2 levels) in create_stemcell'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/bosh_cli_plugin_micro-1.5.0.pre.1181/lib/bosh/deployer/instance_manager.rb:79:in `step'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/bosh_cli_plugin_micro-1.5.0.pre.1181/lib/bosh/deployer/instance_manager.rb:228:in `block in create_stemcell'
/usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/tmpdir.rb:83:in `mktmpdir'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/bosh_cli_plugin_micro-1.5.0.pre.1181/lib/bosh/deployer/instance_manager.rb:214:in `create_stemcell'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/bosh_cli_plugin_micro-1.5.0.pre.1181/lib/bosh/deployer/instance_manager.rb:118:in `create'
"microbosh-openstack/bosh_micro_deploy.log" 215L, 28192C
I have a .yml file set up which I can't really post for security reasons, but I've verified with my IAAS support that i have the correct credentials.
Has anyone seen an error like this on Openstack? Also I am getting a stack trace and half tempted to try debugging. Problem is I'm not well versed on debugging these large open projects. Does anyone know a good resource explaining how to begin debugging them?
The error that you're seeing is caused by OpenStack rejecting the credentials that you're providing. One possible pitfall: are you using your Rackspace account password for "PASSWORD" instead of an API key? You can find your API key by logging in to your account, clicking on your username in the upper-right, and choosing "account settings" from the drop-down. (I'm assuming you're using Rackspace because of the question tags.)
You mentioned that you've verified them with your provider -- perhaps they aren't being passed in correctly? According to the documentation, you should put them in a micro_bosh.yml file with the following form:
# ...
cloud:
plugin: openstack
properties:
openstack:
auth_url: http://<identity_server>:5000/v2.0
username: <username>
api_key: <password>
tenant: <tenant>
region: <region> # Optional
default_security_groups: ["ssh", "bosh"]
default_key_name: <microbosh_keypair>
private_key: <path_to_microbosh_keypar_private_key>
# ...
Remember that YAML is whitespace-sensitive.
As for debugging open-source projects, the best guidance I can give is to not be afraid of the source and to have some patience. The source code for bosh is available on GitHub, so you can easily browse around the source code up your stack trace to try to figure out what's going on. Work backwards from the actual exception or error message that you're seeing; try to determine what was put into an unexpected state, and trace callers to figure out how it could have ended up that way. Reading other people's source code is an incredibly useful skill, and it gets easier with practice, so have at it!

Resources