Skip to content

fix(rest): wait for pending code security attachments and retry on 409 - #972

Merged
heurtematte merged 2 commits into
mainfrom
fix/code-security-attach-retry
Nov 30, 2026
Merged

heurtematte merged 2 commits into
mainfrom
fix/code-security-attach-retry

Conversation

@heurtematte

@heurtematte heurtematte commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Description

otterdog apply could not attach a code security configuration to several repositories in one run. The patches
of the repositories failed one after the other, alternating between two errors:

  • failed retrieving the code security configuration of repo '<repo>': with an empty body, although GitHub did
    attach the configuration;
  • failed to attach code security configuration with name '<name>': {"message":"Another enablement event is in progress. Applying this configuration is not available until it's finished.", ..., "status":"409"}, and the
    repository was not attached.

Each new apply attached only about half of the remaining repositories.

There were two causes:

  1. Right after an attachment request (202), GET /repos/{owner}/{repo}/code-security-configuration answers
    204 No Content until a configuration is attached. wait_for_code_security_configuration treated every status
    other than 200 as an error, so it failed on its first poll instead of waiting. It now treats 204 as "not
    attached yet" and keeps polling, within its existing limit of 10 seconds. Any other status still fails at once.
  2. Since the patch of the previous repository failed without waiting, the attachment request of the next repository
    reached GitHub while the previous enablement was still running, and GitHub rejected it with 409.
    attach_code_security_configuration now sends a request rejected with 409 again, once per second, for up to 30
    attempts. If the conflict is still there after that, the error of GitHub is reported as before. Any other error
    is not sent again.

Creating a repository with code_security_configuration (plain, forked or from a template) goes through the same
attachment and wait, so it is fixed too.

The reference page of code security configurations now gives the 10-second wait for an attachment and the 30-second
retry.

issue related: eclipse-kuksa/.eclipsefdn#39

logs

  Applying changes:

╷                                                                       
│ Error:   failed to apply patch: CHANGE -                              
│          repository[name="kuksa-website"]                             
│          failed retrieving the code security configuration of repo    
│          'kuksa-website':                                             
│                                                                       
╵                                                                       

╷                                                                       
│ Error:   failed to apply patch: CHANGE -                              
│          repository[name="kuksa-hardware"]                            
│          failed to attach code security configuration with name       
│          'kuksa-base-sec':                                            
│          {"message":"Another enablement event is in progress.         
│          Applying this configuration is not available until it's      
│          finished.","documentation_url":"https://docs.github.com/res  
│          t/code-security/configurations#attach-a-configuration-to-re  
│          positories","status":"409"}                                  
╵                                                                       

╷                                                                       
│ Error:   failed to apply patch: CHANGE -                              
│          repository[name="kuksa-android-companion"]                   
│          failed retrieving the code security configuration of repo    
│          'kuksa-android-companion':                                   
│                                                                       
╵                                                                       

╷                                                                       
│ Error:   failed to apply patch: CHANGE -                              
│          repository[name="kuksa-can-provider"]                        
│          failed to attach code security configuration with name       
│          'kuksa-base-sec':                                            
│          {"message":"Another enablement event is in progress.         
│          Applying this configuration is not available until it's      
│          finished.","documentation_url":"https://docs.github.com/res  
│          t/code-security/configurations#attach-a-configuration-to-re  
│          positories","status":"409"}                                  
╵                                                                       

╷                                                                       
│ Error:   failed to apply patch: CHANGE -                              
│          repository[name="kuksa-dds-provider"]                        
│          failed retrieving the code security configuration of repo    
│          'kuksa-dds-provider':                                        
│                                                                       
╵                                                                       

╷                                                                       
│ Error:   failed to apply patch: CHANGE -                              
│          repository[name="kuksa-csv-provider"]                        
│          failed to attach code security configuration with name       
│          'kuksa-base-sec':                                            
│          {"message":"Another enablement event is in progress.         
│          Applying this configuration is not available until it's      
│          finished.","documentation_url":"https://docs.github.com/res  
│          t/code-security/configurations#attach-a-configuration-to-re  
│          positories","status":"409"}                                  
╵                                                                       

╷                                                                       
│ Error:   failed to apply patch: CHANGE -                              
│          repository[name="kuksa-mock-provider"]                       
│          failed retrieving the code security configuration of repo    
│          'kuksa-mock-provider':                                       
│                             

Type of change

  • 🐛 Bug fix (non-breaking change fixing an issue)
  • ✨ New feature (non-breaking change adding functionality)
  • 💥 Breaking change (fix or feature that changes existing behavior, config schema, or default template)
  • 📝 Documentation only
  • 🔧 Refactoring / internal change (no functional change)

Tests

  • Unit tests added / updated under tests/
  • No test added

Manual testing

  • GitHub API calls only stubbed / mocked in unit tests (no live testing)
  • Tested on a real GitHub organization (live GitHub API)

Checklist

  • Documentation updated (docs/, reference docs for new/changed settings, make docs builds):
    docs/reference/organization/code-security-configuration.md
  • Default template / examples updated if the config schema changed: not applicable, neither the schema nor the
    defaults change

Attaching a code security configuration to several repositories in one
apply failed for every repository:

- GitHub answers 204 to GET /repos/{owner}/{repo}/code-security-configuration
  until an accepted attachment is processed. This was reported as an error
  with an empty body, although the repository got attached.
- The attachment of the next repository then reached GitHub while that
  enablement was still in progress, and GitHub rejected it with 409.

While waiting for an attachment, treat a 204 as "not attached yet". Send
an attachment that GitHub rejects with 409 again, once per second, for up
to 30 attempts.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: sebastien.heurtematte <sebastien.heurtematte@eclipse-foundation.org>
@heurtematte
heurtematte temporarily deployed to pull-request-preview November 30, 2026 09:02 — with GitHub Actions Inactive
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

📖 The preview of the documentation was removed (pull request closed).

The polling loops of code security configurations repeated their number of
attempts and their wait as literals, in the loop and in the messages.
Name them as module constants. No behaviour change.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: sebastien.heurtematte <sebastien.heurtematte@eclipse-foundation.org>
@sonarqubecloud

Copy link
Copy Markdown

@heurtematte
heurtematte merged commit f342018 into main Nov 30, 2026
15 checks passed
@heurtematte
heurtematte deleted the fix/code-security-attach-retry branch November 30, 2026 12:50
@heurtematte
heurtematte temporarily deployed to pull-request-preview November 30, 2026 12:50 — with GitHub Actions Inactive

This branch was previously deployed

1 inactive deployment
pull-request-preview — 8c5209df Deployed Nov 30, 2026 by heurtematte via remove the preview #62
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

Successfully merging this pull request may close these issues.

2 participants