-
-
Notifications
You must be signed in to change notification settings - Fork 372
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
[BUG] Danger doesn't work with App tokens anymore #1433
Comments
@orta - Can you weigh in on if this is expected? I'm not bugging you for a fix, necessarily, I know this is all volunteer-time OSS, and I'm very grateful for it. But just knowing if this is expected or not would be super helpful. Thanks! |
@jaymzh this 403 error log isn't necessarily a direct indicator that App Tokens will never work. It's a bit of a confusing log message, but basically, when DangerJS gets the token, it doesn't know what kind of token it is. It hits a series of APIs to figure that out, and this error log pops out in several conditions, but it's not a direct concern (alone). I believe the log is being generated inside of Github's API stack despite the error condition being handled in DangerJS. Most of the projects I've used DangerJS for have that error log message despite Danger working fine. That said, I haven't used App Tokens except for one hello-world project years ago. I mostly use the built-in token, followed by a bot-account token. |
There are some examples of expected 403 errors in the tests here, though I haven't verified if they're exactly the same as your case!
|
Huh, that's an interesting observation. OK, I'll test a bit more deeply, and see if I can validate it's actually functioning completely. Thanks! |
OK after some testing, the problem is that when it can't determine its user, it fails to update existing comments and makes new ones. So this definitely impacts functionality. |
@jaymzh are you sure that your token has permission to edit/remove comments? I don't fully remember, but when using the built-in Github Token (configured via permissions in the workflow), you could easily get into that state unless you added the right permission scope. Similarly, I had this issue when I first created a User Token for this, but it didn't have sufficient read + write / edit permissions. DangerJS is used by so many people in so many ways, that behaving like this is actually an intentional feature. Indeed, some people/projects absolutely never want a comment to be edited or removed, and some CI providers don't even allow such edits -- even though edit/replace on comments is one of the top reasons that some people chose to use DangerJS. So DangerJS needs to support multiple outcomes depending on how you configure it -- it's unfortunate that for your case, a configuration error (for your needs) is interpreted as a "valid" configuration for someone else's needs. |
Yeah I wasn't claiming it was invalid, I totally see it as a valid possible config. I'll double check the perms on the app. Thanks. |
Sorry - on a company onsite - I feel like it was not possible to find out the account of the app which was posting a very long time ago when I added support for app tokens as a GitHub app was new then. Maybe I fixed it by doing some hardcoding the postee in Peril, but it does seem reasonable to either see if that's possible or I'm not against the idea of having app based tokens force Danger is simply look for its own comment to update via the post body? |
I have an action that looks for it's own comments by a magic string (an HTML comment) in the body, and it works well. It's a much much simpler action than Danger, and JS isn't a strong language of mine, so I haven't quite been able to follow Danger's code well enough to make the change, but I think it'd be a reasonable solution. |
I'm tempted to suggest that we close this ticket, and instead delete the App Token method of using DangerJS, but perhaps I'm missing a valid use-case. (Peril covers some, while user-tokens cover others!) -- Because of the security sensitivity of a tool like DangerJS, I'm not sure we should offer a public App Token. Sounds like this isn't a blocker for anyone right now. If somebody else comes along and is motivated, I'd be happy to help review solutions. |
@fbartho - GH support is requiring me to use an App, actually. Here's the details:
|
@jaymzh Thanks for sharing your use-case! If I might ask: Is this all in a large monorepo? Do you commonly have huge PRs with many files edited? Random low-value thoughts that are running through my brain based on your story:
|
No I think I wasn't clear or you misunderstood. The workflow is not editing a workflow. Make a PR like this:
When anythign requests the list of files in the PR, you'll get an error of |
(it's quite common for us to modify several workflow files in a single PR - and SEVERAL of our checks fail, and we're trying to move them all to an App now because of this) |
so I think this is only done in GitHubAPI.ts and only to find Danger's comments. And since there's a magic string in all of Danger's comments, I'm pretty sure it's not needed. |
I suspect I have misunderstood something! Would you mind sharing exactly where "this is only done in GitHubAPI.ts"? Maybe if you show me which magic string you're talking about I'll better understand. |
Well in However, it's not necessary as we already check to make sure the body includes a check for the magic string Oh and the same logic is used to find inline PR comments. Again, I believe we can drop the call to |
Yeah, dropping the user check seems reasonable to me |
I've done this in #1435 |
That's awesome, thanks! |
I've rolled this out and all works well. Thanks! |
Describe the bug
This changelog line from version
0.21.1
claims:But that doesn't seem to be true anymore as when we try to use a token from an App, we get:
Doing a naive grep through he codebase, I only see
/user
referenced in tests (or non-GH platforms), so I'm not quite clear where it's coming from.To Reproduce
Steps to reproduce the behavior:
Expected behavior
Screenshots
Your Environment
GitHub Actions
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: