Forge Lint Missed a Jira Request: Check Required Scopes
In this article
If Forge lint misses a Jira request that needs additional scopes, you must manually check the scopes declared in your app’s manifest.yml against the Jira REST API endpoints your code calls. The lint tool only catches some missing scopes, so a runtime 403 or 404 error is the real signal that a scope is missing. This article explains how to identify the required scopes, update your manifest, and verify the fix.
Why Forge Lint Doesn’t Catch Every Missing Scope
Forge lint is a static analysis tool that checks your app’s code for common issues, including some scope mismatches. However, it has limitations:
- It may not track scopes used inside dynamic URLs, string concatenation, or variables that resolve to API endpoints.
- It only checks code paths it can statically analyze; if a request is made through a helper function or a library, lint might not see it.
- It doesn’t know the full scope requirements of every endpoint, especially newer or less common ones.
Therefore, a missing scope often surfaces only when the app runs and Jira returns an error like 403 FORBIDDEN or 404 NOT FOUND.
How to Identify the Required Scope for a Jira API Call
To find the exact scope for a Jira endpoint, follow these steps:
- Check the Jira REST API documentation for the endpoint you’re calling. Each endpoint lists the required scope under “Authorization” or “Scopes”.
- Look for the scope in the format
read:jira-work,write:jira-work,read:jira-user, etc. - If the endpoint is part of a specific product like Jira Service Management, the scope may be prefixed with
read:servicedesk-requestor similar. - For endpoints that return user information, you may need
read:jira-userin addition to the work scopes. - Use the
@forge/apilibrary’sapi.asApp()orapi.asUser()methods, which automatically include the necessary scopes for the requested resource. - Write a small script that parses your code for all
api.get,api.post, etc., calls and cross-references them with a list of endpoint-scope mappings. - Enable runtime logging in your app to catch 403 errors early in development.
For example, calling GET /rest/api/3/issue/{issueId}/comment requires read:jira-work, while creating a comment with POST requires write:jira-work.
Updating Your Forge App Manifest
Once you know the required scope, add it to your manifest.yml file under the permissions section. The structure looks like this:
permissions:
scopes:
- read:jira-work
- write:jira-work
After editing the manifest, redeploy your app with forge deploy and then forge install to update the installation. If you’re developing locally, you may need to re-run forge tunnel to pick up the changes.
Common Mistakes and Misconceptions
One common mistake is confusing read:jira-work with read:jira-user. The former grants access to issue data, projects, and boards, while the latter is for user profiles and account information. Another misconception is that lint will catch all missing scopes; in reality, it only checks a subset. Also, some endpoints require multiple scopes—for example, adding a user to a project might need both read:jira-user and write:jira-work. Always verify each endpoint individually.
Verifying the Fix After Updating Scopes
After updating the manifest and redeploying, test the specific API call that was failing. You can use the forge run command to test locally, or check the app’s logs in the Forge CLI with forge logs. If the error persists, confirm that the scope you added matches the one listed in the API docs. Also, ensure the app is reinstalled, because scope changes require a new installation to take effect.
Alternatives to Manual Checking
If you want to avoid missing scopes in the future, consider these practices:
Frequently Asked Questions
How do I know which scope is missing if the error is 404?
A 404 can be misleading—it often means the resource isn’t found, but if the endpoint is correct, it may be that the app lacks the scope to see it. Check the API docs for the endpoint and add the required scope, then test again.
Can I use a wildcard scope like *:jira-work?
No, Atlassian does not support wildcard scopes. You must list each scope explicitly. Using a broader scope than needed is possible but not recommended for security.
Does Forge lint ever give false positives for scopes?
Yes, lint may flag a scope as missing when it’s actually provided through a variable or a library. In that case, verify the actual runtime behavior before adding the scope.
Do I need to reinstall the app after changing scopes?
Yes, scope changes require a new installation. You can update an existing installation by running forge install --update or by uninstalling and reinstalling.
What if the endpoint requires a scope that isn’t in the manifest but lint doesn’t complain?
That’s common. Lint only checks a subset. You must manually verify the endpoint’s scope in the docs and add it to the manifest.