Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions skills/drupalorg-cli/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,21 @@ drupalorg maintainer:release-notes <ref1> [ref2] [--format=json|md|html]
```bash
# Install the drupalorg-cli agent skill into .claude/skills/drupalorg-cli/
drupalorg skill:install
```

## Cache Bypass

Drupal.org uses HTTP caching (CDN/Varnish). If you need fresh data — e.g. after a
new comment was posted — pass `--no-cache` to any command:

# Clear the local API cache
drupalorg cache:clear
```bash
drupalorg issue:show <nid> --with-comments --format=llm --no-cache
drupalorg mr:list [nid] --format=llm --no-cache
```

`--no-cache` sends `Cache-Control: no-cache, no-store, must-revalidate` and
`Pragma: no-cache` headers so the upstream CDN returns a fresh response.

Comment on lines +169 to +171
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs state --no-cache sends Cache-Control: no-cache, no-store, must-revalidate, but must-revalidate isn’t a request directive and may be ignored. Update this section to reflect the actual (standards-aligned) request headers that will be sent after adjusting the client header value.

Suggested change
`--no-cache` sends `Cache-Control: no-cache, no-store, must-revalidate` and
`Pragma: no-cache` headers so the upstream CDN returns a fresh response.
`--no-cache` sends a `Cache-Control: no-cache` request header so the upstream CDN will revalidate and return a fresh response where supported.

Copilot uses AI. Check for mistakes.
## Error Handling

| Error | Cause | Recovery |
Expand Down
18 changes: 12 additions & 6 deletions src/Api/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Client
*/
public const API_URL = 'https://www.drupal.org/api-d7/';

public function __construct()
public function __construct(bool $noCache = false)
{
$stack = HandlerStack::create();
$stack->push(GuzzleRetryMiddleware::factory([
Expand All @@ -31,16 +31,22 @@ public function __construct()
'default_retry_multiplier' => 1.5,
]), 'retry');

$headers = [
'User-Agent' => 'DrupalOrgCli/0.0.1',
'Accept' => 'application/json',
'Accept-Encoding' => '*',
];
if ($noCache) {
$headers['Cache-Control'] = 'no-cache, no-store, max-age=0';
$headers['Pragma'] = 'no-cache';
}
Comment on lines 25 to +42
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new --no-cache behavior is user-facing and implemented in the HTTP client constructor, but there’s no test asserting that new Client(true) actually sets the expected request headers on the underlying Guzzle client. Since the repo has PHPUnit coverage for actions, please add a small unit test for Client that inspects the Guzzle client config/handler to verify the headers are applied when the flag is enabled (and absent when disabled).

Copilot uses AI. Check for mistakes.

$this->client = new \GuzzleHttp\Client(
[
'base_uri' => self::API_URL,
'cookies' => true,
'handler' => $stack,
'headers' => [
'User-Agent' => 'DrupalOrgCli/0.0.1',
'Accept' => 'application/json',
'Accept-Encoding' => '*',
],
'headers' => $headers,
]
);
}
Expand Down
14 changes: 14 additions & 0 deletions src/Cli/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use Composer\InstalledVersions;
use Symfony\Component\Console\Application as ParentApplication;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputOption;

class Application extends ParentApplication
{
Expand All @@ -23,6 +25,18 @@ public function __construct()
$this->addCommands($this->getCommands());
}

protected function getDefaultInputDefinition(): InputDefinition
{
$definition = parent::getDefaultInputDefinition();
$definition->addOption(new InputOption(
'no-cache',
null,
InputOption::VALUE_NONE,
'Bypass Drupal.org HTTP caching and fetch a fresh response.'
));
return $definition;
}

/**
* @return \Symfony\Component\Console\Command\Command[]
*/
Expand Down
3 changes: 2 additions & 1 deletion src/Cli/Command/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ protected function initialize(
) : $output;
$this->stdIn = $input;
self::$interactive = $input->isInteractive();
$this->client = new Client();
$noCache = $input->hasOption('no-cache') && (bool) $input->getOption('no-cache');
$this->client = new Client($noCache);
}

protected function debug(string $message): void
Expand Down