Skip to content

weko#62759 Fix title auto-fill leaving the title blank for non-standard item types - #1912

Open
MakotoASAOKA wants to merge 1 commit into
develop_v2.0.5from
fix/issue62759
Open

weko#62759 Fix title auto-fill leaving the title blank for non-standard item types#1912
MakotoASAOKA wants to merge 1 commit into
develop_v2.0.5from
fix/issue62759

Conversation

@MakotoASAOKA

@MakotoASAOKA MakotoASAOKA commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

状況

weko_items_ui/app.jsautoSetTitle() / isExistingTitle() / updateTitleForOutputReport() が、タイトルのsubitemキー名を subitem_item_title / subitem_item_title_language に固定している。この名前を使わない item type (例: scripts/demo/resticted_access.sql が登録する制限公開参照アイテムタイプの subitem_restricted_access_item_title) では、value.items.properties.hasOwnProperty(titleSubKey) が常に false になり、タイトル自動設定機能でタイトルがレコードモデルに一切反映されず、保存後もタイトルが空欄のままになる。

再現手順

  1. subitem_item_title 以外の名前でタイトルのsubitemを定義した item type を用意する
  2. WEKO_ITEMS_UI_AUTO_FILL_TITLE_SETTING 等でこの item type に対しタイトル自動設定を有効にする
  3. この item type で新規アイテム登録画面を開く
  4. タイトル欄が自動入力されず空欄のまま保存されることを確認する

併せて、item_type の title プロパティが言語サブキーを持たない場合(例: item_1578299480500)、autoSetTitle() が無条件に enTitle[titleLanguageKey]/jaTitle[titleLanguageKey] を設定しようとし、配列要素がスキーマと不整合になって登録自体が失敗する問題も含む。

回避策(修正前)

無し。タイトル自動設定機能に依存する item type ではタイトルを手動入力する必要があった。

改修範囲

  • modules/weko-workflow/weko_workflow/views.py: item_type_mapping の jpcoar_mapping.title から実際のタイトルsubitemキー名・言語サブキー名を動的に解決する get_title_subitem_keys() を追加し、display_activity() のレンダリングコンテキストに渡す
  • modules/weko-items-ui/weko_items_ui/templates/weko_items_ui/iframe/item_edit.html: 上記の値を保持する隠しinputを2つ追加(title_subitem_key / title_language_subitem_key)
  • modules/weko-items-ui/weko_items_ui/static/js/weko_items_ui/app.js: ハードコードされていた3箇所を、上記隠しinputから動的に取得する形に変更(値が無い場合は従来通り subitem_item_title/subitem_item_title_language にフォールバック)。あわせて、スキーマに言語サブキーが定義されている場合のみ設定するガードを追加
  • modules/weko-workflow/tests/test_views.py: get_title_subitem_keys() の単体テストを追加(既存 item_type フィクスチャでの解決確認、マッピング無し/存在しないIDでの安全なフォールバック確認)。ローカルで実行し2件とも成功を確認済み

ブランチ名

fix/issue62759

プルリクエストURL

(この PR 自体)

Summary by Sourcery

Make automatic title handling compatible with item-type-specific title schemas.

Bug Fixes:

  • Fix automatic title population and existing-title detection for item types that use non-standard title subitem keys.
  • Prevent title generation from adding an undeclared language field when the item type schema does not define one.

Enhancements:

  • Resolve title and language subitem keys from each item type's JPCOAR mapping, with fallback to the standard keys when unavailable.

Tests:

  • Add coverage for title-key resolution and safe fallback behavior when mappings are missing or invalid.

@sourcery-ai

sourcery-ai Bot commented Sep 3, 2026

Copy link
Copy Markdown

Reviewer's Guide

Fix title auto-fill for item types with non-standard title subitem names by resolving keys from jpcoar mappings, passing them to the edit UI, and guarding language-field assignment against schemas that omit language subitems.

Sequence diagram for dynamic title auto-fill

sequenceDiagram
    participant Workflow as display_activity()
    participant Mapping as Mapping.get_record()
    participant Template as item_edit.html
    participant UI as autoSetTitle()
    participant Model as invenioRecordsModel

    Workflow->>Mapping: get_record(item_type_id)
    Mapping-->>Workflow: jpcoar_mapping.title keys
    Workflow->>Template: render title_subitem_key and title_language_subitem_key
    Template-->>UI: hidden input values
    UI->>UI: Read resolved keys with fallback
    UI->>Model: Store generated title under titleSubKey
    alt language subitem exists
        UI->>Model: Store language value under titleLanguageKey
    end
Loading

File-Level Changes

Change Details Files
Resolve title and language subitem keys from each item type instead of assuming the standard JPCOAR names.
  • Extract title mapping keys from the item type's jpcoar_mapping.title entry.
  • Pass the resolved keys through the activity rendering context and hidden edit-form inputs.
  • Use dynamic keys in title detection, auto-fill, output-report handling, and field disabling, with legacy-name fallbacks.
modules/weko-workflow/weko_workflow/views.py
modules/weko-items-ui/weko_items_ui/templates/weko_items_ui/iframe/item_edit.html
modules/weko-items-ui/weko_items_ui/static/js/weko_items_ui/app.js
Prevent auto-filled title records from containing language fields that are not defined by the item type schema.
  • Check whether the resolved language subitem exists before assigning English and Japanese language values.
  • Continue populating the title value while omitting undeclared language properties.
modules/weko-items-ui/weko_items_ui/static/js/weko_items_ui/app.js
Add coverage for title-key resolution and safe fallback behavior.
  • Verify keys are resolved from an existing item type mapping.
  • Verify missing or invalid mappings return empty keys without raising errors.
modules/weko-workflow/tests/test_views.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 06d0190a-0983-4cc4-9616-155f297ab8c1

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Fix title auto-fill for item-specific title schemas

🐞 Bug fix 🧪 Tests 🕐 20-40 Minutes

Grey Divider

AI Description

• Resolve title and language keys from each item type’s JPCOAR mapping.
• Auto-fill non-standard title schemas without injecting undeclared language fields.
• Preserve standard-key fallbacks and test resolver behavior for missing mappings.
Diagram

sequenceDiagram
    participant W as Workflow View
    participant M as Mapping Store
    participant T as Edit Template
    participant J as Items UI JS
    participant S as Record Schema
    W->>M: Resolve title keys
    M-->>W: Return mapped keys
    W->>T: Render hidden keys
    T->>J: Expose title keys
    J->>S: Find title property
    alt Language key declared
        J->>S: Write titles and languages
    else No language key
        J->>S: Write titles only
    end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Extract a shared title-key resolver
  • ➕ Avoids duplicating JPCOAR title-mapping interpretation across workflow and deposit modules.
  • ➕ Provides one reusable contract for future title-processing features.
  • ➖ Broadens this targeted bug fix into a cross-module refactor.
  • ➖ Existing deposit title resolution also considers form options and hidden fields, complicating reuse.
2. Discover title fields entirely in JavaScript
  • ➕ Avoids passing additional values through the server-rendered template.
  • ➕ Keeps auto-fill behavior within the client-side schema processor.
  • ➖ The JSON schema alone may not identify which property is the semantic JPCOAR title.
  • ➖ Would duplicate mapping semantics or require exposing more mapping data to the browser.

Recommendation: The PR’s server-side resolution and hidden-input bridge is the best focused fix because the item-type mapping is authoritative and the template already carries auto-fill settings. A shared resolver could reduce long-term duplication, but it is better handled separately after reconciling workflow and deposit-specific title-selection rules.

Files changed (4) +87 / -10

Bug fix (3) +63 / -9
app.jsUse mapped keys for all automatic title operations +23/-8

Use mapped keys for all automatic title operations

• Replaces hardcoded title and language subitem names in existing-title detection, auto-fill, field disabling, and output-report updates. Falls back to standard JPCOAR names and only adds language values when the active schema declares the language property.

modules/weko-items-ui/weko_items_ui/static/js/weko_items_ui/app.js

item_edit.htmlExpose resolved title keys to the item editor +2/-0

Expose resolved title keys to the item editor

• Adds hidden inputs carrying the item type’s resolved title and language subitem keys for client-side title handling.

modules/weko-items-ui/weko_items_ui/templates/weko_items_ui/iframe/item_edit.html

views.pyResolve item-specific title keys during activity rendering +38/-1

Resolve item-specific title keys during activity rendering

• Adds a helper that reads title and language subitem keys from each item type’s JPCOAR title mapping. The activity view passes the resolved values into the rendering context while safely returning empty values when no mapping exists.

modules/weko-workflow/weko_workflow/views.py

Tests (1) +24 / -1
test_views.pyTest title-key mapping resolution and safe fallbacks +24/-1

Test title-key mapping resolution and safe fallbacks

• Adds coverage confirming that title keys are read from an existing item-type mapping. Also verifies that missing or absent item-type identifiers return empty fallback values without errors.

modules/weko-workflow/tests/test_views.py

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Fixed security issues:

  • Cross-site scripting (XSS) via untrusted HTML/JS injection in web rendering sinks (link)
Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="modules/weko-workflow/weko_workflow/views.py" line_range="822-826" />
<code_context>
+        for mapping_value in item_type_mapping.values():
+            if not isinstance(mapping_value, dict):
+                continue
+            jpcoar_title = (mapping_value.get('jpcoar_mapping') or {}).get('title')
+            if isinstance(jpcoar_title, dict) and jpcoar_title.get('@value'):
+                title_subitem_key = jpcoar_title.get('@value')
+                title_language_subitem_key = jpcoar_title.get(
+                    '@attributes', {}).get('xml:lang') or ""
+                break
+    return title_subitem_key, title_language_subitem_key
+
</code_context>
<issue_to_address>
**issue (bug_risk):** A truthy non-dict `jpcoar_mapping` value causes `(mapping_value.get('jpcoar_mapping') or {}).get('title')` to raise `AttributeError`, and a non-dict `@attributes` value causes the subsequent `.get('@attributes', {}).get(...)` chain to raise as well. The helper is documented and tested as a safe fallback, but malformed mapping data makes the item-edit page fail instead of returning empty keys.

**Triggers:** When an item type mapping contains a non-empty malformed `jpcoar_mapping` or `@attributes` value.

**Suggested fix:** Check that `jpcoar_mapping` and `@attributes` are dictionaries before calling `.get()`, or catch malformed mapping data and retain the empty-key fallback.

```suggestion
            jpcoar_mapping = mapping_value.get('jpcoar_mapping')
            if not isinstance(jpcoar_mapping, dict):
                continue
            jpcoar_title = jpcoar_mapping.get('title')
            if isinstance(jpcoar_title, dict) and jpcoar_title.get('@value'):
                title_subitem_key = jpcoar_title.get('@value')
                jpcoar_attributes = jpcoar_title.get('@attributes')
                if isinstance(jpcoar_attributes, dict):
                    title_language_subitem_key = jpcoar_attributes.get(
                        'xml:lang') or ""
```
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 1 finding to address first, and if the resolved subitem key or language key is wrong, auto-fill can write an incorrect title into saved item metadata, and reverting would not remove titles already saved. Those records remain editable and the values can be corrected or regenerated, so the impact is bounded and repairable.

Blocking findings: modules/weko-workflow/weko_workflow/views.py:826


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +822 to +826
jpcoar_title = (mapping_value.get('jpcoar_mapping') or {}).get('title')
if isinstance(jpcoar_title, dict) and jpcoar_title.get('@value'):
title_subitem_key = jpcoar_title.get('@value')
title_language_subitem_key = jpcoar_title.get(
'@attributes', {}).get('xml:lang') or ""

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): A truthy non-dict jpcoar_mapping value causes (mapping_value.get('jpcoar_mapping') or {}).get('title') to raise AttributeError, and a non-dict @attributes value causes the subsequent .get('@attributes', {}).get(...) chain to raise as well. The helper is documented and tested as a safe fallback, but malformed mapping data makes the item-edit page fail instead of returning empty keys.

Triggers: When an item type mapping contains a non-empty malformed jpcoar_mapping or @attributes value.

Suggested fix: Check that jpcoar_mapping and @attributes are dictionaries before calling .get(), or catch malformed mapping data and retain the empty-key fallback.

Suggested change
jpcoar_title = (mapping_value.get('jpcoar_mapping') or {}).get('title')
if isinstance(jpcoar_title, dict) and jpcoar_title.get('@value'):
title_subitem_key = jpcoar_title.get('@value')
title_language_subitem_key = jpcoar_title.get(
'@attributes', {}).get('xml:lang') or ""
jpcoar_mapping = mapping_value.get('jpcoar_mapping')
if not isinstance(jpcoar_mapping, dict):
continue
jpcoar_title = jpcoar_mapping.get('title')
if isinstance(jpcoar_title, dict) and jpcoar_title.get('@value'):
title_subitem_key = jpcoar_title.get('@value')
jpcoar_attributes = jpcoar_title.get('@attributes')
if isinstance(jpcoar_attributes, dict):
title_language_subitem_key = jpcoar_attributes.get(
'xml:lang') or ""

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (5) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. PR title lacks prefix 📘 Rule violation ⚙ Maintainability
Description
The PR title weko#62759 Fix title auto-fill leaving the title blank for non-standard item types
does not begin with a lowercase prefix followed by : . It therefore fails the required `^[a-z]+:
\S.*$` format.
Code

modules/weko-items-ui/weko_items_ui/static/js/weko_items_ui/app.js[2179]

+        // The subitem key used for an item type's title varies by item
Evidence
PR Compliance ID 3024944 requires a lowercase prefix such as fix:, but the supplied PR title
starts with weko#62759.

Rule 3024944: Enforce prefixed pull request title format


2. app.js behavior lacks tests 📘 Rule violation ▣ Testability
Description
The PR changes title lookup and introduces the hasLanguageKey branch in app.js, but the added
tests only exercise the Python key resolver. The client-side behavior for non-standard keys and
schemas without language fields therefore lacks regression coverage.
Code

modules/weko-items-ui/weko_items_ui/static/js/weko_items_ui/app.js[R2255-2258]

+                  if (hasLanguageKey) {
+                    enTitle[titleLanguageKey] = "en";
+                    jaTitle[titleLanguageKey] = "ja";
+                  }
Evidence
The changed JavaScript conditionally writes language values and dynamically resolves title keys,
while the only added tests call get_title_subitem_keys() and do not execute the client-side
branches.

Rule 3024926: Require tests for new or modified production code
modules/weko-items-ui/weko_items_ui/static/js/weko_items_ui/app.js[2237-2259]
modules/weko-workflow/tests/test_views.py[4632-4650]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The modified automatic-title behavior in `app.js` is not covered by tests.

## Issue Context
Add regression cases for non-standard title subitem keys, existing-title detection, and title schemas that omit the language subitem key.

## Fix Focus Areas
- modules/weko-items-ui/weko_items_ui/static/js/weko_items_ui/app.js[2178-2259]
- modules/weko-items-ui/weko_items_ui/static/js/weko_items_ui/app.js[5284-5285]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Mapping import is unsorted 📘 Rule violation ⚙ Maintainability
Description
The newly added Mapping member is placed after ItemApplication rather than in alphabetic order.
This violates the configured isort sorting requirement for from-import members.
Code

modules/weko-workflow/weko_workflow/views.py[61]

+from weko_records.api import FeedbackMailList, RequestMailList, ItemLink, ItemTypes, ItemApplication, Mapping
Evidence
The changed import appends Mapping after ItemApplication, although alphabetic ordering places it
before RequestMailList; the project enables isort with profile=black.

Rule 3024936: Order Python imports according to isort sections and sort rules
modules/weko-workflow/weko_workflow/views.py[61-61]
modules/weko-workflow/tox.ini[34-35]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The modified `weko_records.api` import does not alphabetize its imported members.

## Issue Context
The module's tox configuration uses isort with the Black profile. Run isort or manually place `Mapping` in the resulting alphabetical order.

## Fix Focus Areas
- modules/weko-workflow/weko_workflow/views.py[61-61]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View medium (2)
4. Helper fails Black formatting 📘 Rule violation ⚙ Maintainability
Description
The newly added helper uses formatting that Black would rewrite, including single-quoted string
literals. Consequently, black --check would not accept the modified Python code unchanged.
Code

modules/weko-workflow/weko_workflow/views.py[R822-826]

+            jpcoar_title = (mapping_value.get('jpcoar_mapping') or {}).get('title')
+            if isinstance(jpcoar_title, dict) and jpcoar_title.get('@value'):
+                title_subitem_key = jpcoar_title.get('@value')
+                title_language_subitem_key = jpcoar_title.get(
+                    '@attributes', {}).get('xml:lang') or ""
Evidence
The added helper contains single-quoted literals such as 'jpcoar_mapping', 'title', and
'@value', which Black's default string normalization rewrites; the lint environment explicitly
runs black ..

Rule 3024931: Format Python code with Black and reject non-compliant diffs
modules/weko-workflow/weko_workflow/views.py[822-826]
modules/weko-workflow/tox.ini[78-87]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The added `get_title_subitem_keys()` implementation is not in Black-normalized form.

## Issue Context
The repository lint environment invokes `black .`; run the configured formatter and commit its changes to the modified Python files.

## Fix Focus Areas
- modules/weko-workflow/weko_work_workflow/views.py[800-828]
- modules/weko-workflow/tests/test_views.py[4631-4650]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. Missing function separation 📘 Rule violation ✧ Quality
Description
The new top-level get_title_subitem_keys() definition has only one blank line after the preceding
function. Flake8 reports this as E305, so the touched Python file does not pass static analysis.
Code

modules/weko-workflow/weko_workflow/views.py[800]

+def get_title_subitem_keys(item_type_id):
Evidence
The preceding function ends on line 798, followed by only line 799 as a blank line before the new
top-level definition on line 800; the Flake8 configuration does not ignore E305.

Rule 3024934: Python code must pass Flake8 static analysis checks with no violations
modules/weko-workflow/weko_workflow/views.py[798-800]
modules/weko-workflow/tox.ini[26-32]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new top-level helper is not separated from the preceding function by two blank lines.

## Issue Context
Flake8 requires two blank lines before a top-level function definition and reports the current layout as `E305`.

## Fix Focus Areas
- modules/weko-workflow/weko_workflow/views.py[798-800]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context sources
✅ Compliance rules (platform): 13 rules
Review mode: ⚖️ Balanced: This behavioral fix spans backend mapping resolution, template data flow, and multiple JavaScript title-handling paths, so it carries meaningful integration risk but is not unusually defect-dense enough to warrant extended review.

Grey Divider

Tip of the day
💡 Did you know, you can add REVIEW.md to your repo root and Qodo follows it on every PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

};

$scope.isExistingTitle = function () {
// The subitem key used for an item type's title varies by item

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

1. Pr title lacks prefix 📘 Rule violation ⚙ Maintainability

The PR title weko#62759 Fix title auto-fill leaving the title blank for non-standard item types
does not begin with a lowercase prefix followed by : . It therefore fails the required `^[a-z]+:
\S.*$` format.

Comment on lines +2255 to +2258
if (hasLanguageKey) {
enTitle[titleLanguageKey] = "en";
jaTitle[titleLanguageKey] = "ja";
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

2. app.js behavior lacks tests 📘 Rule violation ▣ Testability

The PR changes title lookup and introduces the hasLanguageKey branch in app.js, but the added
tests only exercise the Python key resolver. The client-side behavior for non-standard keys and
schemas without language fields therefore lacks regression coverage.
Agent Prompt
## Issue description
The modified automatic-title behavior in `app.js` is not covered by tests.

## Issue Context
Add regression cases for non-standard title subitem keys, existing-title detection, and title schemas that omit the language subitem key.

## Fix Focus Areas
- modules/weko-items-ui/weko_items_ui/static/js/weko_items_ui/app.js[2178-2259]
- modules/weko-items-ui/weko_items_ui/static/js/weko_items_ui/app.js[5284-5285]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

get_current_user
from weko_logging.activity_logger import UserActivityLogger
from weko_records.api import FeedbackMailList, RequestMailList, ItemLink, ItemTypes, ItemApplication
from weko_records.api import FeedbackMailList, RequestMailList, ItemLink, ItemTypes, ItemApplication, Mapping

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

3. mapping import is unsorted 📘 Rule violation ⚙ Maintainability

The newly added Mapping member is placed after ItemApplication rather than in alphabetic order.
This violates the configured isort sorting requirement for from-import members.
Agent Prompt
## Issue description
The modified `weko_records.api` import does not alphabetize its imported members.

## Issue Context
The module's tox configuration uses isort with the Black profile. Run isort or manually place `Mapping` in the resulting alphabetical order.

## Fix Focus Areas
- modules/weko-workflow/weko_workflow/views.py[61-61]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +822 to +826
jpcoar_title = (mapping_value.get('jpcoar_mapping') or {}).get('title')
if isinstance(jpcoar_title, dict) and jpcoar_title.get('@value'):
title_subitem_key = jpcoar_title.get('@value')
title_language_subitem_key = jpcoar_title.get(
'@attributes', {}).get('xml:lang') or ""

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

4. Helper fails black formatting 📘 Rule violation ⚙ Maintainability

The newly added helper uses formatting that Black would rewrite, including single-quoted string
literals. Consequently, black --check would not accept the modified Python code unchanged.
Agent Prompt
## Issue description
The added `get_title_subitem_keys()` implementation is not in Black-normalized form.

## Issue Context
The repository lint environment invokes `black .`; run the configured formatter and commit its changes to the modified Python files.

## Fix Focus Areas
- modules/weko-workflow/weko_work_workflow/views.py[800-828]
- modules/weko-workflow/tests/test_views.py[4631-4650]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


return jsonify(res), 200

def get_title_subitem_keys(item_type_id):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

5. Missing function separation 📘 Rule violation ✧ Quality

The new top-level get_title_subitem_keys() definition has only one blank line after the preceding
function. Flake8 reports this as E305, so the touched Python file does not pass static analysis.
Agent Prompt
## Issue description
The new top-level helper is not separated from the preceding function by two blank lines.

## Issue Context
Flake8 requires two blank lines before a top-level function definition and reports the current layout as `E305`.

## Fix Focus Areas
- modules/weko-workflow/weko_workflow/views.py[798-800]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

whose title subitem key isn't subitem_item_title

autoSetTitle()/isExistingTitle()/updateTitleForOutputReport() in
weko_items_ui/app.js hardcoded the title subitem key names
(subitem_item_title / subitem_item_title_language). Item types whose
title property uses a different subitem key (e.g.
subitem_restricted_access_item_title, used by the restricted-access
reference item type from scripts/demo/resticted_access.sql) never
match `value.items.properties.hasOwnProperty(titleSubKey)`, so the
autofilled title is silently never written into the record model and
the title field is left blank.

Resolve the subitem key names dynamically instead, from the item
type's own item_type_mapping (the same jpcoar_mapping.title source
weko_deposit.api.WekoDeposit.get_titles already uses), via a new
weko_workflow.views.get_title_subitem_keys() passed through
display_activity()'s render_template call and two new hidden inputs
in item_edit.html (title_subitem_key / title_language_subitem_key),
falling back to the standard subitem_item_title(/_language) names if
nothing can be resolved.

Also guard the language sub-key assignment in autoSetTitle() behind
an explicit schema check: some title properties (e.g.
item_1578299480500 on item types 3007/3008) declare no language
sibling field at all, and unconditionally assigning one produced an
array item the record could not be saved with.

Adds weko_workflow/tests/test_views.py::test_get_title_subitem_keys(_no_mapping)
covering the new helper.
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

API インベントリ差分(件数のみ)

⚠️ プライベートリポジトリに対応ブランチが無いため、既定ブランチの台帳と比較しています。
ブランチ間の経路差がそのまま差分として出るので、以下の件数は当てになりません。
この PR のブランチと同名のブランチをプライベートリポジトリに作ってください。

明細は公開できないため件数のみ表示しています。該当箇所はプライベートリポジトリ側の台帳・レポートで確認してください。

ベースラインとの差分

API インベントリ差分レポート

  • 旧: e9c5b2b51 v2.0.3-69-ge9c5b2b51 (profile=default) endpoints=928 (外部ライブラリ由来 359)
  • 新: 3f74cd313 v2.0.4-41-g3f74cd313 (profile=default) endpoints=928 (外部ライブラリ由来 359)

判定: ✅ PASS (FAIL 0 / WARN 2)

サマリ

分類 件数
ADDED 0
REMOVED 0
RULE_CHANGED 0
METHODS_CHANGED 0
AUTH_CHANGED 0
IMPL_CHANGED 2
ATTRS_UNKNOWN_NEW 0
ModelView 追加 0
ModelView 削除 0
ModelView フラグ変化 1
config 変化 0
コメントアウト認証の増加 0
依存パッケージの版変化 40

[WARN] W2 実装本体が変化(data_op / 情報露出を再確認) — 2件

件数のみ。該当の経路名はプライベートリポジトリ側の完全版レポートを参照。

[WARN] W6 依存パッケージの版が変化した — 40件

  • attrs — 22.2.0 -> 17.4.0
  • botocore — 1.12.209 -> 1.12.253
  • cffi — 1.15.1 -> 1.11.2
  • click — 8.0.4 -> 6.7
  • cryptography — 40.0.2 -> 2.1.4
  • pyld — 3.1.0 -> 3.3.0
  • pytest — 7.0.1 -> 4.2.0
  • Docker-Services-CLI — 0.8.0 -> (削除)
  • aws-xray-sdk — 0.95 -> (削除)
  • build — 0.9.0 -> (削除)
  • check-manifest — 0.48 -> (削除)
  • cookies — 2.2.1 -> (削除)
  • coverage — 4.5.4 -> (削除)
  • docker — 5.0.3 -> (削除)
  • ecdsa — 0.19.2 -> (削除)
  • execnet — 1.9.0 -> (削除)
  • iniconfig — 1.1.1 -> (削除)
  • isort — 5.10.1 -> (削除)
  • jsondiff — 1.1.1 -> (削除)
  • jsonpickle — 2.2.0 -> (削除)
  • mock — 3.0.5 -> (削除)
  • moto — 1.3.7 -> (削除)
  • pep517 — 0.13.1 -> (削除)
  • pep8 — 1.7.1 -> (削除)
  • pyaml — 23.5.8 -> (削除)
  • pycryptodome — 3.21.0 -> (削除)
  • pydocstyle — 6.3.0 -> (削除)
  • pytest-cache — 1.0 -> (削除)
  • pytest-cov — 2.10.1 -> (削除)
  • pytest-flask — 0.15.1 -> (削除)
  • pytest-invenio — 1.3.4 -> (削除)
  • pytest-mock — 3.6.1 -> (削除)
  • pytest-pep8 — 1.0.6 -> (削除)
  • python-jose — 2.0.2 -> (削除)
  • responses — 0.10.15 -> (削除)
  • selenium — 3.141.0 -> (削除)
  • tomli — 1.2.3 -> (削除)
  • websocket-client — 1.3.1 -> (削除)
  • weko-redis — 0.1.0.dev20170000 -> (削除)
  • wrapt — 1.16.0 -> (削除)

台帳との突き合わせ

スナップショット ↔ インベントリ 突き合わせ

  • リビジョン: 3f74cd313 v2.0.4-41-g3f74cd313 経路URI=908
  • 台帳: 行=1048 URI=919

件数のみ。詳細はプライベートリポジトリ側の完全版レポートを参照。

判定: ✅ 一致 (0件)

検出 件数
A. インベントリ未収載(抽出漏れ) 0
B. 実機に無い(未説明) 0
B'. 実機に無い(既知・許容) 11
C. メソッド不一致 0
D. app列の不一致 0
E. endpoint 未収載 0
E'. endpoint が実機に無い(参考) 1

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.

1 participant